/* ==========================================================================
   Oito Maluco — jogo de descarte contra o computador, cartas desenhadas em CSS e naipes em SVG próprios
   ========================================================================== */

.oito {
  --om-mesa-1: #a35d2c;
  --om-mesa-2: #6a3517;
  --om-face: #fffdf8;
  --om-borda: #cfc5b3;
  --om-preta: #1c1a17;
  --om-vermelha: #c3261f;
  --om-verso-1: #24417a;
  --om-verso-2: #111f45;
  --om-verso-borda: #e9cf7e;
  --om-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");
  --om-reciclar: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M78 30A36 36 0 1 0 86 58' fill='none' stroke='%23000' stroke-width='12' stroke-linecap='round'/%3E%3Cpath d='M90 8v36H54z'/%3E%3C/svg%3E");
  max-width: 760px;
  margin: 0 auto;
  overflow-x: clip;
}
:root[data-theme="dark"] .oito {
  --om-mesa-1: #8a4a22;
  --om-mesa-2: #4d250f;
  --om-face: #f4f0e7;
}

.oito .om-modos {
  justify-content: center;
  margin-bottom: 14px;
}

.om-info {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.om-dado {
  padding: 8px 10px;
  text-align: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.om-dado span {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.om-dado strong {
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.om-partida {
  margin: 8px 0 12px;
  font-size: 13.5px;
  text-align: center;
  color: var(--muted);
}

/* ---------- Mesa ---------- */
.om-mesa {
  --cw: 60px;
  --ch: 84px;
  position: relative;
  /* As cartas usam z-index alto; isolar evita que passem por cima do cabeçalho fixo do site. */
  isolation: isolate;
  width: 100%;
  min-height: 300px;
  background:
    radial-gradient(120% 80% at 50% 45%, rgba(255, 255, 255, 0.09), transparent 62%),
    linear-gradient(180deg, var(--om-mesa-1), var(--om-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;
}

/* Lugar de cada adversário: nome, cartas e pontos; o leque de cartas fica por cima */
.om-assento {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  box-sizing: border-box;
  padding: 5px 8px 0;
  color: #fff;
  background: rgba(0, 0, 0, 0.16);
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  outline: none;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}
.om-assento[hidden] {
  display: none;
}
.om-assento-topo {
  display: block;
  line-height: 1.2;
}
.om-nome {
  font-size: 14px;
  font-weight: 800;
}
.om-detalhe {
  display: block;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
  text-overflow: ellipsis;
  opacity: 0.86;
}
.om-assento.om-vez-dele {
  border-color: var(--om-destaque);
  box-shadow: 0 0 0 2px rgba(255, 210, 63, 0.3), 0 0 18px rgba(255, 210, 63, 0.35);
}
.om-assento.om-vez-dele .om-nome::after {
  content: " · joga";
  font-weight: 700;
  color: var(--om-destaque);
}
.om-assento.om-venceu {
  border-color: #9df0b4;
}

.om-ultima {
  padding: 2px 7px;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1.3;
  white-space: nowrap;
  color: #3a2200;
  background: var(--om-destaque);
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  animation: om-pulsar 900ms ease-in-out infinite alternate;
}
.om-ultima[hidden] {
  display: none;
}
.om-assento .om-ultima {
  position: absolute;
  top: -9px;
  right: 6px;
}
.om-ultima-voce {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 960;
  transform: translateY(-50%);
  font-size: 12px;
}

.om-pilha {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  box-sizing: border-box;
  display: grid;
  place-items: center;
  border: 2px dashed rgba(255, 255, 255, 0.22);
  border-radius: calc(var(--cw) * 0.1);
  outline: none;
}
.om-pilha-monte {
  cursor: pointer;
}
/* Espessura do monte: aparece sob a carta de cima */
.om-pilha-monte.cheio {
  border-style: solid;
  border-color: transparent;
  box-shadow:
    2px 3px 0 -1px rgba(17, 31, 69, 0.95),
    4px 6px 0 -2px rgba(17, 31, 69, 0.6);
}
.om-pilha-monte.vazio {
  cursor: default;
  border-color: rgba(255, 255, 255, 0.16);
}
.om-pilha-monte.reciclar,
.om-pilha-monte.passar {
  cursor: pointer;
  border-color: rgba(255, 255, 255, 0.4);
}
.om-pilha-monte.reciclar::after {
  content: "";
  position: absolute;
  inset: 26%;
  background: rgba(255, 255, 255, 0.6);
  -webkit-mask: var(--om-reciclar) center / contain no-repeat;
  mask: var(--om-reciclar) center / contain no-repeat;
}
.om-pilha-monte.passar {
  border-style: solid;
  border-color: var(--om-destaque);
}
.om-pilha-texto {
  padding: 0 4px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  color: rgba(255, 255, 255, 0.85);
}
.om-pilha-monte.passar .om-pilha-texto {
  color: var(--om-destaque);
}
.om-pilha.om-chama {
  animation: om-chamar 1s ease-in-out infinite alternate;
}
.om-pilha.om-dica {
  animation: om-brilho 550ms ease-in-out 4 alternate;
}

.om-naipe-da-vez {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 900;
  box-sizing: border-box;
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 6px 10px;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #5b4a36;
  background: rgba(255, 253, 248, 0.96);
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.32);
  transform: translateY(-50%);
  pointer-events: none;
}
.om-naipe-da-vez.visivel {
  display: flex;
  animation: om-surgir 260ms ease-out;
}
.om-naipe-da-vez-nome {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--om-preta);
}
.om-naipe-da-vez.vermelho .om-naipe-da-vez-nome {
  color: var(--om-vermelha);
}
.om-naipe-da-vez .om-naipe {
  width: 20px;
  height: 20px;
  flex: none;
}

.om-vez {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  pointer-events: none;
}
.om-vez {
  font-size: 14px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
.om-vez.om-sua-vez {
  color: var(--om-destaque);
}

.om-vagas {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.om-vaga {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  outline: none;
  pointer-events: auto;
}
.om-vaga[hidden] {
  display: none;
}

.om-anel {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3000;
  box-sizing: border-box;
  border-radius: calc(var(--cw) * 0.12);
  outline: 3px solid var(--om-destaque);
  outline-offset: 2px;
  pointer-events: none;
}
.om-anel.om-anel-assento {
  border-radius: 12px;
}

.om-mensagem {
  position: absolute;
  left: 50%;
  top: 0;
  z-index: 3500;
  width: max-content;
  max-width: calc(100% - 24px);
  box-sizing: border-box;
  margin: 0;
  padding: 9px 14px;
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
  color: #fff;
  background: rgba(30, 14, 4, 0.92);
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  opacity: 0;
  translate: -50% calc(-50% + 6px);
  transition: opacity 160ms ease, translate 160ms ease;
}
.om-mensagem.visivel {
  opacity: 1;
  translate: -50% -50%;
}

/* ---------- Cartas ---------- */
.om-carta {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--cw);
  height: var(--ch);
  transition:
    translate 320ms ease,
    scale 320ms ease,
    rotate 320ms ease;
  touch-action: manipulation;
}
.om-carta.coberta {
  visibility: hidden;
}
.om-mesa.sem-animacao .om-carta {
  transition: none;
}
.om-face {
  position: absolute;
  inset: 0;
  border-radius: calc(var(--cw) * 0.1);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  transition:
    translate 140ms ease,
    box-shadow 160ms ease,
    filter 160ms ease;
}
.om-frente,
.om-verso {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  border-radius: inherit;
}
.om-frente {
  overflow: hidden;
  color: var(--om-preta);
  background: var(--om-face);
  border: 1px solid var(--om-borda);
}
.om-carta.vermelha .om-frente {
  color: var(--om-vermelha);
}
.om-verso {
  background:
    radial-gradient(circle at 50% 50%, rgba(233, 207, 126, 0.5) 0 12%, transparent 13%),
    repeating-linear-gradient(45deg, rgba(233, 207, 126, 0.16) 0 2px, transparent 2px 7px),
    repeating-linear-gradient(-45deg, rgba(233, 207, 126, 0.16) 0 2px, transparent 2px 7px),
    linear-gradient(150deg, var(--om-verso-1), var(--om-verso-2));
  border: max(2px, calc(var(--cw) * 0.05)) solid var(--om-verso-borda);
}

.om-valor {
  position: absolute;
  top: 2%;
  left: 6%;
  font-family: "Nunito", sans-serif;
  font-size: calc(var(--cw) * 0.34);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.07em;
}
.om-naipe {
  display: block;
  background-color: currentColor;
  -webkit-mask: var(--naipe) center / contain no-repeat;
  mask: var(--naipe) center / contain no-repeat;
}
.om-naipe-espadas {
  --naipe: var(--naipe-espadas);
}
.om-naipe-copas {
  --naipe: var(--naipe-copas);
}
.om-naipe-ouros {
  --naipe: var(--naipe-ouros);
}
.om-naipe-paus {
  --naipe: var(--naipe-paus);
}
.om-naipe-canto {
  position: absolute;
  top: 4%;
  right: 6%;
  width: calc(var(--cw) * 0.27);
  height: calc(var(--cw) * 0.27);
}
.om-centro {
  position: absolute;
  right: 18%;
  bottom: 9%;
  left: 18%;
  height: 46%;
  display: grid;
  place-items: center;
}
.om-centro .om-naipe {
  width: 100%;
  height: 100%;
}
.om-figura {
  right: 15%;
  bottom: 8%;
  left: 15%;
  height: 50%;
  padding-top: 0.06em;
  font-family: "Baloo 2", sans-serif;
  font-size: calc(var(--cw) * 0.5);
  font-weight: 800;
  line-height: 1;
  border: max(1px, calc(var(--cw) * 0.025)) solid currentColor;
  border-radius: calc(var(--cw) * 0.08);
}

/* Sua mão: as que servem sobem e brilham, as outras ficam apagadas */
.om-carta.om-da-mao {
  cursor: pointer;
}
.om-carta.jogavel .om-face {
  box-shadow: 0 0 0 2px var(--om-destaque), 0 5px 12px rgba(0, 0, 0, 0.38);
}
@media (hover: hover) {
  .om-carta.jogavel:hover .om-face {
    translate: 0 -8px;
  }
}
.om-carta.apagada .om-face {
  filter: brightness(0.6) saturate(0.7);
}
.om-carta.om-focada {
  z-index: 950 !important;
}
.om-carta.om-focada .om-face {
  translate: 0 calc(var(--ch) * -0.08);
  filter: none;
}
.om-carta.om-nova .om-face {
  animation: om-nova 1300ms ease-out;
}
.om-carta.om-dica .om-face {
  animation: om-brilho 550ms ease-in-out 4 alternate;
}
.om-carta.om-chama .om-face {
  animation: om-chamar 1s ease-in-out infinite alternate;
}
.om-face.virando {
  animation: om-virar 220ms ease-out;
}
.om-face.tremendo {
  animation: om-tremer 320ms ease-in-out;
}
.om-mesa.om-festa .om-carta.aberta .om-face {
  animation: om-pulo 520ms ease-in-out calc(var(--k, 0) * 90ms) 2;
}
@keyframes om-brilho {
  to {
    box-shadow: 0 0 0 3px var(--om-destaque), 0 0 18px 4px rgba(255, 210, 63, 0.85);
  }
}
@keyframes om-chamar {
  from {
    box-shadow: 0 0 0 2px rgba(255, 210, 63, 0.4), 0 1px 2px rgba(0, 0, 0, 0.35);
  }
  to {
    box-shadow: 0 0 0 3px var(--om-destaque), 0 0 16px 3px rgba(255, 210, 63, 0.7);
  }
}
@keyframes om-nova {
  from {
    box-shadow: 0 0 0 3px #fff, 0 0 18px 6px rgba(255, 255, 255, 0.8);
  }
}
@keyframes om-virar {
  from {
    scale: 0.06 1;
  }
}
@keyframes om-tremer {
  20%,
  60% {
    rotate: -5deg;
  }
  40%,
  80% {
    rotate: 5deg;
  }
}
@keyframes om-pulo {
  50% {
    scale: 1.12;
    rotate: -6deg;
  }
}
@keyframes om-pulsar {
  to {
    scale: 1.08;
  }
}
@keyframes om-surgir {
  from {
    opacity: 0;
    scale: 0.8;
  }
}

/* ---------- Botões, placar e estatísticas ---------- */
.om-botoes {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
}
.om-botoes .button,
.om-botoes .som-botao {
  min-height: 44px;
}
.om-botoes .button {
  padding: 10px 18px;
}
.om-botoes .button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.om-botoes .button[hidden] {
  display: none;
}

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

.om-placar,
.om-estatisticas {
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.om-placar summary,
.om-estatisticas summary {
  font-size: 14px;
  font-weight: 650;
  color: var(--text-2);
  cursor: pointer;
}
.om-tabela {
  overflow-x: auto;
  margin-top: 10px;
}
.om-tabela table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.om-tabela th,
.om-tabela td {
  padding: 6px 8px;
  text-align: center;
  border-top: 1px solid var(--border);
}
.om-tabela thead th {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  border-top: 0;
}
.om-tabela tbody th,
.om-tabela tfoot th {
  font-weight: 600;
  color: var(--muted);
}
.om-tabela td {
  color: var(--text-2);
}
.om-tabela td.ganhou {
  font-weight: 800;
  color: var(--text);
}
.om-tabela td.vazio {
  font-size: 13.5px;
  color: var(--muted);
}
.om-tabela tfoot td,
.om-tabela tfoot th {
  border-top: 2px solid var(--border-2);
  font-weight: 800;
  color: var(--text);
}
.om-tabela tfoot td.lider {
  color: var(--accent);
}
:root[data-theme="light"] .om-tabela tfoot td.lider {
  color: #92400e;
}

.om-est-lista {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px 18px;
  margin: 12px 0 0;
}
.om-est-lista div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.om-est-lista dt {
  color: var(--muted);
}
.om-est-lista dd {
  margin: 0;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.om-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álogos ---------- */
.om-dialogo {
  width: min(92vw, 420px);
  max-height: calc(100vh - 32px);
  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);
}
.om-dialogo::backdrop {
  background: rgba(10, 12, 16, 0.6);
}
.om-dialogo h2 {
  margin: 0 0 8px;
  font-size: 23px;
}
.om-dialogo p {
  margin: 0 0 14px;
  color: var(--text-2);
}
.om-dialogo h3 {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-align: left;
  text-transform: uppercase;
  color: var(--muted);
}
.om-dialogo-dados {
  display: grid;
  gap: 6px;
  margin: 0 0 16px;
  text-align: left;
}
.om-dialogo-dados div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}
.om-dialogo-dados dt {
  color: var(--muted);
}
.om-dialogo-dados dd {
  margin: 0;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.om-dialogo-dados .destaque dt,
.om-dialogo-dados .destaque dd {
  font-weight: 800;
  color: var(--accent);
}
:root[data-theme="light"] .om-dialogo-dados .destaque dt,
:root[data-theme="light"] .om-dialogo-dados .destaque dd {
  color: #92400e;
}
.om-dialogo-botoes {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.om-dialogo.travado .om-dialogo-botoes,
.om-dialogo.travado .om-naipes-botoes {
  pointer-events: none;
}

.om-naipes-botoes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 16px;
}
.om-naipe-botao {
  display: grid;
  justify-items: center;
  gap: 3px;
  min-height: 92px;
  padding: 12px 8px 10px;
  font: inherit;
  color: var(--om-preta);
  background: var(--om-face);
  border: 2px solid var(--om-borda);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 140ms ease, box-shadow 140ms ease, translate 140ms ease;
}
.om-naipe-botao.vermelho {
  color: var(--om-vermelha);
}
.om-naipe-botao .om-naipe {
  width: 34px;
  height: 34px;
}
.om-naipe-botao span {
  font-size: 15px;
  font-weight: 800;
}
.om-naipe-botao small {
  font-size: 12px;
  color: #6b6155;
}
.om-naipe-botao:hover,
.om-naipe-botao:focus-visible {
  border-color: var(--om-destaque);
  box-shadow: 0 0 0 3px rgba(255, 210, 63, 0.45);
  translate: 0 -2px;
  outline: none;
}

@media (max-width: 420px) {
  /* Os três modos cabem numa linha só */
  .oito .om-modos {
    gap: 6px;
  }
  .oito .om-modos .filter {
    padding: 8px 10px;
  }
  .om-info {
    gap: 6px;
  }
  .om-dado {
    padding: 6px 4px;
  }
  .om-dado strong {
    font-size: 17px;
  }
  .om-botoes {
    gap: 8px;
  }
  .om-botoes .button {
    padding: 10px 14px;
  }
  /* Cartas pequenas: o valor cresce um pouco */
  .om-valor {
    font-size: calc(var(--cw) * 0.4);
  }
  .om-naipe-canto {
    width: calc(var(--cw) * 0.3);
    height: calc(var(--cw) * 0.3);
  }
  .om-mensagem {
    font-size: 13px;
  }
  .om-nome {
    font-size: 13px;
  }
  .om-detalhe {
    font-size: 11.5px;
  }
  .om-assento {
    padding: 4px 6px 0;
  }
  .om-naipe-da-vez {
    padding: 5px 8px;
  }
  .om-naipe-da-vez-nome {
    font-size: 14px;
  }
  .om-tabela th,
  .om-tabela td {
    padding: 5px 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .om-carta,
  .om-face,
  .om-mensagem {
    transition: none;
  }
  .om-carta.om-dica .om-face,
  .om-pilha.om-dica {
    animation: none;
    box-shadow: 0 0 0 3px var(--om-destaque);
  }
  .om-face.virando,
  .om-face.tremendo,
  .om-carta.om-nova .om-face,
  .om-carta.om-chama .om-face,
  .om-pilha.om-chama,
  .om-ultima,
  .om-naipe-da-vez.visivel,
  .om-mesa.om-festa .om-carta.aberta .om-face {
    animation: none;
  }
}
