/* ==========================================================================
   Buraco — dois baralhos, você contra o computador; cartas desenhadas em CSS e naipes em SVG próprios
   ========================================================================== */

.buraco {
  --bu-mesa-1: #4b3e8e;
  --bu-mesa-2: #261d52;
  --bu-painel: rgba(8, 4, 30, 0.2);
  --bu-texto: #f5f2ff;
  --bu-texto-2: rgba(245, 242, 255, 0.74);
  --bu-face: #fffdf8;
  --bu-borda: #cfc5b3;
  --bu-preta: #1c1a17;
  --bu-vermelha: #c3261f;
  --bu-verso-1: #b5452f;
  --bu-verso-2: #6e1f14;
  --bu-verso-borda: #f1d9a1;
  --bu-destaque: #ffd23f;
  --naipe-espadas: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M50 3C71 25 95 41 95 62c0 13-10 23-23 23-8 0-15-4-19-10 1 9 5 16 13 22H34c8-6 12-13 13-22-4 6-11 10-19 10C15 85 5 75 5 62 5 41 29 25 50 3z'/%3E%3C/svg%3E");
  --naipe-copas: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M50 93C22 71 4 53 4 32 4 17 15 7 29 7c9 0 16 5 21 13 5-8 12-13 21-13 14 0 25 10 25 25 0 21-18 39-46 61z'/%3E%3C/svg%3E");
  --naipe-ouros: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M50 2 88 50 50 98 12 50z'/%3E%3C/svg%3E");
  --naipe-paus: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='28' r='21'/%3E%3Ccircle cx='27' cy='60' r='21'/%3E%3Ccircle cx='73' cy='60' r='21'/%3E%3Cpath d='M44 40h12v20c0 15 4 26 14 37H30c10-11 14-22 14-37z'/%3E%3C/svg%3E");
  max-width: 1000px;
  margin: 0 auto;
  overflow-x: clip;
}
:root[data-theme="dark"] .buraco {
  --bu-mesa-1: #3d3277;
  --bu-mesa-2: #1c1540;
  --bu-face: #f4f0e7;
}

/* ---------- Modos, placar ---------- */
.bu-topo {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 18px;
  margin-bottom: 12px;
}
.bu-placar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  max-width: 460px;
  margin: 0 auto;
}
.bu-lado {
  padding: 6px 10px;
  text-align: center;
  background: var(--surface-2);
  border: 2px solid var(--border);
  border-radius: var(--r-sm);
  transition: border-color 160ms ease;
}
.bu-lado.vez {
  border-color: var(--accent);
}
.bu-quem {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.bu-lado strong {
  display: block;
  font-size: 22px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.bu-na-mesa {
  display: block;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.bu-x {
  font-weight: 800;
  color: var(--muted);
}
.bu-partida {
  margin: 8px 0 10px;
  font-size: 13.5px;
  text-align: center;
  color: var(--muted);
}

/* ---------- Mesa ---------- */
.bu-mesa {
  --mw: 40px;
  --mh: 56px;
  position: relative;
  /* As cartas usam z-index alto; isolar evita que passem por cima do cabeçalho fixo do site. */
  isolation: isolate;
  display: grid;
  grid-template-rows: auto minmax(64px, 1fr) auto auto minmax(64px, 1fr) auto auto;
  gap: 6px;
  box-sizing: border-box;
  height: clamp(470px, calc(100vh - 200px), 640px);
  padding: 8px 10px 10px;
  color: var(--bu-texto);
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(255, 255, 255, 0.09), transparent 62%),
    linear-gradient(180deg, var(--bu-mesa-1), var(--bu-mesa-2));
  border-radius: var(--r-sm);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25), inset 0 3px 22px rgba(0, 0, 0, 0.3);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
@supports (height: 100svh) {
  .bu-mesa {
    height: clamp(470px, calc(100svh - 200px), 640px);
  }
}

.bu-faixa {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  min-height: 26px;
}
.bu-faixa-texto {
  flex: none;
  margin: 0;
  font-size: 13.5px;
  line-height: 1.3;
  color: var(--bu-texto-2);
}
.bu-faixa-texto strong {
  color: var(--bu-texto);
}
.bu-faixa.ativa .bu-faixa-texto strong::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  vertical-align: 1px;
  background: var(--bu-destaque);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(255, 210, 63, 0.3);
}
.bu-mao-pc {
  --cw: 28px;
  --ch: 39px;
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  height: var(--ch);
}
.bu-ordenar {
  flex: none;
  min-height: 28px;
  padding: 3px 12px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--bu-texto);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  cursor: pointer;
}
.bu-ordenar:hover {
  background: rgba(255, 255, 255, 0.2);
}
.bu-ordenar:focus-visible {
  outline: 3px solid var(--bu-destaque);
  outline-offset: 2px;
}

/* ---------- Jogos baixados ---------- */
.bu-jogos {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px 12px;
  min-height: 0;
  padding: 6px 8px 8px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  background: var(--bu-painel);
  border-radius: 10px;
}
.bu-vazio {
  margin: auto;
  font-size: 13px;
  color: var(--bu-texto-2);
}
.bu-jogo {
  position: relative;
  flex: none;
  box-sizing: content-box;
  margin: 0;
  padding: 16px 0 0;
  font: inherit;
  color: inherit;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 8px;
  outline: none;
}
.bu-jogo-voce {
  cursor: pointer;
}
.bu-jogo-cartas {
  position: relative;
  display: block;
  height: var(--mh);
}
.bu-jogo .bu-carta {
  --cw: var(--mw);
  --ch: var(--mh);
}
.bu-selo {
  position: absolute;
  top: 0;
  left: 0;
  padding: 0 6px;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 14px;
  white-space: nowrap;
  color: var(--bu-texto-2);
  border-radius: 7px;
}
.bu-jogo.canastra .bu-selo {
  color: #2b2100;
  background: #ffd23f;
}
.bu-jogo.suja .bu-selo {
  color: #1d2233;
  background: #cdd5e6;
}
.bu-jogo.canastra .bu-jogo-cartas {
  border-radius: calc(var(--mw) * 0.1);
  box-shadow: 0 0 0 2px rgba(255, 210, 63, 0.75);
}
.bu-jogo.suja .bu-jogo-cartas {
  box-shadow: 0 0 0 2px rgba(205, 213, 230, 0.7);
}
.bu-jogo.encaixa .bu-jogo-cartas {
  outline: 2px dashed var(--bu-destaque);
  outline-offset: 3px;
}
.bu-jogo:focus-visible .bu-jogo-cartas,
.bu-monte:focus-visible,
.bu-lixo:focus-visible {
  outline: 3px solid var(--bu-destaque);
  outline-offset: 3px;
}
.bu-carta.curinga .bu-frente {
  box-shadow: inset 0 0 0 2px #e0a800;
}
.bu-carta.curinga .bu-valor {
  padding: 0 1px;
  color: #2b2100;
  background: var(--bu-destaque);
  border-radius: 3px;
}

/* ---------- Monte, mortos e lixo ---------- */
.bu-centro {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-width: 0;
  padding: 0 2px;
}
.bu-pilha {
  flex: none;
}
.bu-legenda {
  display: block;
  margin-bottom: 3px;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--bu-texto-2);
}
.bu-monte,
.bu-mortos,
.bu-lixo {
  position: relative;
  flex: none;
  border-radius: 8px;
  outline: none;
}
.bu-monte {
  cursor: pointer;
}
.bu-pilha-cartas {
  position: relative;
  display: block;
  width: var(--mw);
  height: var(--mh);
}
.bu-pilha-cartas .bu-carta {
  --cw: var(--mw);
  --ch: var(--mh);
}
.bu-vaga {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  border: 2px dashed rgba(255, 255, 255, 0.2);
  border-radius: calc(var(--mw) * 0.1);
}
.bu-contagem {
  position: absolute;
  right: -9px;
  bottom: -6px;
  z-index: 60;
  min-width: 24px;
  padding: 1px 5px;
  font-size: 11.5px;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: #2b2100;
  background: var(--bu-destaque);
  border-radius: 9px;
}
.bu-mortos-cartas {
  position: relative;
  display: flex;
  gap: 5px;
  height: var(--mh);
  align-items: center;
}
.bu-mortos-cartas .bu-carta {
  --cw: calc(var(--mw) * 0.72);
  --ch: calc(var(--mh) * 0.72);
  position: relative;
}
.bu-mortos-cartas .bu-sem {
  font-size: 12px;
  color: var(--bu-texto-2);
}
.bu-lixo {
  flex: 1 1 auto;
  min-width: 0;
  cursor: pointer;
}
.bu-lixo-cartas {
  position: relative;
  display: block;
  min-height: var(--mh);
}
.bu-lixo-cartas .bu-carta {
  --cw: var(--mw);
  --ch: var(--mh);
}
.bu-lixo-cartas .bu-vaga {
  width: var(--mw);
  height: var(--mh);
}

.bu-fase {
  justify-self: center;
  max-width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 4px 14px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  color: var(--bu-texto);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
}
.bu-fase.sua-vez {
  color: #fff6d6;
  background: rgba(255, 210, 63, 0.16);
  border-color: rgba(255, 210, 63, 0.65);
}

/* ---------- Mão ---------- */
.bu-mao {
  --cw: 60px;
  --ch: 84px;
  position: relative;
  min-height: calc(var(--ch) + 16px);
}
.bu-mao .bu-carta {
  cursor: pointer;
}

.bu-mensagem {
  position: absolute;
  top: 46%;
  left: 50%;
  z-index: 3500;
  width: max-content;
  max-width: calc(100% - 24px);
  box-sizing: border-box;
  margin: 0;
  padding: 10px 16px;
  font-size: 14.5px;
  line-height: 1.4;
  text-align: center;
  color: #fff;
  background: rgba(14, 8, 34, 0.94);
  border: 1px solid rgba(255, 210, 63, 0.5);
  border-radius: 12px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  opacity: 0;
  translate: -50% 6px;
  transition: opacity 160ms ease, translate 160ms ease;
}
.bu-mensagem.visivel {
  opacity: 1;
  translate: -50% 0;
}

.bu-voo {
  position: absolute;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
}

/* ---------- Cartas ---------- */
.bu-carta {
  position: absolute;
  top: 0;
  left: 0;
  box-sizing: border-box;
  width: var(--cw);
  height: var(--ch);
  border-radius: calc(var(--cw) * 0.1);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  transition: translate 140ms ease;
  outline: none;
}
.bu-carta.em-voo {
  visibility: hidden;
}
.bu-frente,
.bu-verso {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  border-radius: inherit;
}
.bu-frente {
  overflow: hidden;
  color: var(--bu-preta);
  background: var(--bu-face);
  border: 1px solid var(--bu-borda);
}
.bu-carta.vermelha .bu-frente {
  color: var(--bu-vermelha);
}
.bu-carta.de-costas .bu-frente {
  visibility: hidden;
}
.bu-verso {
  background:
    radial-gradient(circle at 50% 50%, rgba(241, 217, 161, 0.55) 0 12%, transparent 13%),
    repeating-linear-gradient(45deg, rgba(241, 217, 161, 0.18) 0 2px, transparent 2px 7px),
    repeating-linear-gradient(-45deg, rgba(241, 217, 161, 0.18) 0 2px, transparent 2px 7px),
    linear-gradient(150deg, var(--bu-verso-1), var(--bu-verso-2));
  border: max(2px, calc(var(--cw) * 0.06)) solid var(--bu-verso-borda);
}
/* O valor e o naipe ficam um embaixo do outro no canto esquerdo, que aparece nas cartas sobrepostas */
.bu-valor {
  position: absolute;
  top: 3%;
  left: 7%;
  font-family: "Nunito", sans-serif;
  font-size: calc(var(--cw) * 0.36);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.07em;
}
.bu-naipe {
  display: block;
  background-color: currentColor;
  -webkit-mask: var(--naipe) center / contain no-repeat;
  mask: var(--naipe) center / contain no-repeat;
}
.bu-naipe-espadas {
  --naipe: var(--naipe-espadas);
}
.bu-naipe-copas {
  --naipe: var(--naipe-copas);
}
.bu-naipe-ouros {
  --naipe: var(--naipe-ouros);
}
.bu-naipe-paus {
  --naipe: var(--naipe-paus);
}
.bu-naipe-canto {
  position: absolute;
  top: calc(var(--cw) * 0.42);
  left: 8%;
  width: calc(var(--cw) * 0.27);
  height: calc(var(--cw) * 0.27);
}
.bu-centro-carta {
  position: absolute;
  right: 10%;
  bottom: 8%;
  left: 30%;
  height: 46%;
  display: grid;
  place-items: center;
}
.bu-centro-carta .bu-naipe {
  width: 100%;
  height: 100%;
}
.bu-figura {
  left: 32%;
  right: 9%;
  bottom: 8%;
  height: 48%;
  padding-top: 0.06em;
  font-family: "Baloo 2", sans-serif;
  font-size: calc(var(--cw) * 0.4);
  font-weight: 800;
  line-height: 1;
  border: max(1px, calc(var(--cw) * 0.025)) solid currentColor;
  border-radius: calc(var(--cw) * 0.08);
}

.bu-carta.escolhida {
  translate: 0 -12px;
  box-shadow: 0 0 0 3px var(--bu-destaque), 0 6px 14px rgba(0, 0, 0, 0.45);
}
.bu-mao .bu-carta:focus-visible {
  box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--bu-destaque);
}
.bu-carta.nova::after {
  content: "";
  position: absolute;
  top: -7px;
  left: calc(var(--cw) * 0.14);
  width: 8px;
  height: 8px;
  background: var(--bu-destaque);
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35);
}

/* Cartas em viagem de uma pilha para outra: uma cópia anda e a carta de verdade aparece no fim */
.bu-fantasma {
  z-index: 1000;
  transform-origin: 0 0;
  transition: none;
  pointer-events: none;
}
.bu-fantasma.voando {
  z-index: 1100;
  transition:
    translate 320ms cubic-bezier(0.3, 0.7, 0.3, 1),
    scale 320ms cubic-bezier(0.3, 0.7, 0.3, 1);
}
.bu-carta.virando {
  animation: bu-virar 200ms ease-out;
}
.bu-carta.tremendo {
  animation: bu-tremer 320ms ease-in-out;
}
.bu-dica,
.bu-jogo.bu-dica .bu-jogo-cartas {
  animation: bu-brilho 550ms ease-in-out 4 alternate;
}
.button.bu-dica {
  animation: bu-pulso 550ms ease-in-out 4 alternate;
}
@keyframes bu-brilho {
  to {
    box-shadow: 0 0 0 3px var(--bu-destaque), 0 0 18px 4px rgba(255, 210, 63, 0.8);
  }
}
@keyframes bu-pulso {
  to {
    box-shadow: 0 0 0 4px rgba(255, 210, 63, 0.75);
  }
}
@keyframes bu-virar {
  from {
    scale: 0.06 1;
  }
}
@keyframes bu-tremer {
  20%,
  60% {
    rotate: -5deg;
  }
  40%,
  80% {
    rotate: 5deg;
  }
}

/* ---------- Botões, ajuda, placar e estatísticas ---------- */
.bu-acoes,
.bu-botoes {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}
.bu-botoes {
  margin-top: 10px;
}
.bu-acoes .button,
.bu-botoes .button,
.bu-botoes .som-botao {
  min-height: 44px;
}
.bu-acoes .button,
.bu-botoes .button {
  padding: 8px 16px;
  font-size: 15px;
}
.bu-acoes .button[aria-disabled="true"] {
  opacity: 0.42;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.bu-ajuda {
  margin: 14px 0 0;
  font-size: 13.5px;
  text-align: center;
  color: var(--muted);
}

.bu-detalhes {
  margin-top: 14px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.bu-detalhes summary {
  font-size: 14px;
  font-weight: 650;
  color: var(--text-2);
  cursor: pointer;
}
.bu-tabela {
  width: 100%;
  margin-top: 10px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  border-collapse: collapse;
}
.bu-tabela th,
.bu-tabela td {
  padding: 6px 8px;
  text-align: right;
  border-top: 1px solid var(--border);
}
.bu-tabela th:first-child,
.bu-tabela td:first-child {
  text-align: left;
}
.bu-tabela thead th {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  border-top: 0;
}
.bu-tabela tfoot td,
.bu-tabela .total td {
  font-weight: 800;
  color: var(--text);
}
.bu-tabela td small {
  display: block;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
}
.bu-est-lista {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px 18px;
  margin: 12px 0 0;
}
.bu-est-lista div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.bu-est-lista dt {
  color: var(--muted);
}
.bu-est-lista dd {
  margin: 0;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.bu-zerar {
  margin-top: 12px;
  padding: 0;
  font: inherit;
  font-size: 13.5px;
  color: var(--link);
  text-decoration: underline;
  background: none;
  border: 0;
  cursor: pointer;
}

/* ---------- Diálogo ---------- */
.bu-dialogo {
  width: min(92vw, 420px);
  max-height: 92vh;
  box-sizing: border-box;
  padding: 22px;
  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);
}
.bu-dialogo::backdrop {
  background: rgba(10, 12, 16, 0.6);
}
.bu-dialogo h2 {
  margin: 0 0 8px;
  font-size: 24px;
}
.bu-dialogo p {
  margin: 0 0 14px;
  color: var(--text-2);
}
.bu-dialogo-tabela .bu-tabela {
  margin: 0 0 16px;
}
.bu-dialogo-dados {
  display: grid;
  gap: 8px;
  margin: 0 0 18px;
  text-align: left;
}
.bu-dialogo-dados div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.bu-dialogo-dados dt {
  color: var(--muted);
}
.bu-dialogo-dados dd {
  margin: 0;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.bu-dialogo-dados .destaque dt {
  font-weight: 800;
  color: var(--accent);
}
:root[data-theme="light"] .bu-dialogo-dados .destaque dt {
  color: #92400e;
}
.bu-dialogo-botoes {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.bu-dialogo.travado .bu-dialogo-botoes {
  pointer-events: none;
}

/* ---------- Telas estreitas: a mesa vira uma coluna, e os jogos rolam dentro dela ---------- */
@media (max-width: 699px) {
  .bu-mesa,
  .bu-mesa:is(*) {
    display: flex;
    flex-direction: column;
    height: auto;
    padding: 6px 6px 8px;
    gap: 5px;
  }
  .bu-jogos-pc {
    flex: none;
    height: 104px;
  }
  .bu-jogos-voce {
    flex: none;
    height: 124px;
  }
  .bu-centro {
    gap: 10px;
  }
  .bu-fase {
    align-self: center;
    font-size: 13.5px;
  }
  .bu-acoes {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .bu-acoes .button,
  .bu-botoes .button {
    padding: 8px 10px;
  }
}

@media (max-width: 420px) {
  .bu-lado strong {
    font-size: 19px;
  }
  .bu-faixa-texto {
    font-size: 12.5px;
  }
  .bu-legenda {
    font-size: 9.5px;
  }
  .bu-mensagem {
    font-size: 13.5px;
  }
  .bu-tabela {
    font-size: 13px;
  }
  .bu-tabela th,
  .bu-tabela td {
    padding: 5px 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bu-carta,
  .bu-mensagem {
    transition: none;
  }
  .bu-dica,
  .bu-jogo.bu-dica .bu-jogo-cartas,
  .button.bu-dica {
    animation: none;
    box-shadow: 0 0 0 3px var(--bu-destaque);
  }
  .bu-carta.virando,
  .bu-carta.tremendo {
    animation: none;
  }
}
