.legend {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-bottom: 12px;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.legend b.a { color: #38bdf8; }
.legend b.b { color: #4ade80; }

.dn-score {
  display: flex;
  justify-content: center;
  gap: 22px;
  flex-wrap: wrap;
  margin: 0 0 14px;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.dn-score b { color: #fff; font-size: 1.05rem; }

.mesa-jogadores {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 0 0 16px;
}
.jogador-card {
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: #000;
}
.jogador-card strong,
.jogador-card small { display: block; }
.jogador-card strong {
  font-family: var(--font-display);
  font-style: italic;
  text-transform: uppercase;
  font-size: 0.95rem;
}
.jogador-card small { color: var(--muted); font-size: 0.72rem; margin-top: 4px; }
.jogador-card .jogador-meta {
  margin-top: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
}
.jogador-card.turno { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.jogador-card.voce { border-color: #38bdf8; }
.jogador-card.vazio { opacity: 0.55; border-style: dashed; }
.jogador-card.off .jogador-meta { color: var(--muted); }

.mesa-wrapper {
  background:
    radial-gradient(ellipse 80% 60% at 50% 40%, rgba(255, 255, 255, .06), transparent 60%),
    linear-gradient(180deg, rgba(0, 0, 0, .12) 0%, transparent 18%),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .03) 0 2px, transparent 2px 4px),
    linear-gradient(160deg, #1b7a32 0%, #146b28 45%, #0f5420 100%);
  padding: 28px 16px;
  margin: 0 auto 16px;
  min-height: 360px;
  border: 1px solid var(--line);
  overflow: auto;
  max-width: 100%;
}
.mesa-wrapper.turno-ativo { box-shadow: inset 0 0 0 2px var(--accent); }
.mesa-wrapper.turno-inativo { box-shadow: inset 0 0 0 2px #3f3f3f; }
.mesa {
  position: relative;
  min-width: 100%;
  min-height: 300px;
  margin: 0 auto;
}
.mesa.mesa-vazia {
  display: flex;
  align-items: center;
  justify-content: center;
}
.mesa-placeholder {
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.dn-acoes {
  display: none;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin: 0 0 16px;
}

.mao {
  border: 1px solid var(--line);
  background: #000;
  padding: 16px;
  margin: 0 0 16px;
}
.mao-titulo {
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 10px;
}

.status-block small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  font-size: 0.85rem;
}

.peca,
.domino-peca {
  --domino-w: 64px;
  --domino-h: 128px;
  --domino-radius: 10px;
  --domino-face: linear-gradient(165deg, #fffef9 0%, #f3ebe0 38%, #e8dfd2 100%);
  --domino-edge: #2a211c;
  background: var(--domino-face);
  border: 2px solid var(--domino-edge);
  border-radius: var(--domino-radius);
  display: flex;
  cursor: default;
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .92) inset,
    0 -2px 0 rgba(0, 0, 0, .06) inset,
    0 10px 20px rgba(0, 0, 0, .28),
    0 4px 8px rgba(0, 0, 0, .16);
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}
.peca::before,
.domino-peca::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, .55), transparent 38%),
    repeating-linear-gradient(-18deg, rgba(255, 255, 255, .04) 0 2px, rgba(0, 0, 0, .015) 2px 4px);
  pointer-events: none;
  z-index: 1;
}
.peca::after,
.domino-peca::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: calc(var(--domino-radius) - 4px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .5), inset 0 -6px 12px rgba(120, 100, 78, .08);
  pointer-events: none;
  z-index: 2;
}
.peca.horizontal {
  --domino-w: 128px;
  --domino-h: 64px;
  width: var(--domino-w);
  height: var(--domino-h);
  flex-direction: row;
}
.peca.vertical {
  width: var(--domino-w);
  height: var(--domino-h);
  flex-direction: column;
}
.peca.clicavel { cursor: pointer; }
.peca.mesa-peca {
  position: absolute;
  cursor: default;
  z-index: 1;
}
.peca.mesa-peca:hover { z-index: 2; }
.peca.mesa-peca.last { box-shadow: 0 0 0 3px #facc15, 0 10px 20px rgba(0, 0, 0, .28); }
.peca.clicavel:hover {
  transform: translateY(-8px) rotate(-1deg);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .95) inset,
    0 14px 28px rgba(0, 0, 0, .32),
    0 6px 12px rgba(0, 0, 0, .18);
}
.peca-lado {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  place-items: center;
  padding: 8px;
  position: relative;
  z-index: 3;
  background: linear-gradient(180deg, rgba(255, 255, 255, .14) 0%, rgba(0, 0, 0, .03) 100%);
}
.horizontal .peca-lado:first-child::after,
.vertical .peca-lado:first-child::after {
  content: "";
  position: absolute;
  background: linear-gradient(90deg, rgba(0, 0, 0, .08) 0%, rgba(40, 32, 28, .95) 45%, rgba(255, 255, 255, .25) 50%, rgba(40, 32, 28, .95) 55%, rgba(0, 0, 0, .08) 100%);
  pointer-events: none;
  z-index: 4;
}
.horizontal .peca-lado:first-child::after {
  top: 6px;
  bottom: 6px;
  right: -1px;
  width: 3px;
}
.vertical .peca-lado:first-child::after {
  left: 6px;
  right: 6px;
  bottom: -1px;
  height: 3px;
  background: linear-gradient(180deg, rgba(0, 0, 0, .08) 0%, rgba(40, 32, 28, .95) 45%, rgba(255, 255, 255, .25) 50%, rgba(40, 32, 28, .95) 55%, rgba(0, 0, 0, .08) 100%);
}
.pip {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #6e6e6e 0%, #3a3a3a 38%, #1a1a1a 72%, #000 100%);
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, .22), inset 0 -1px 2px rgba(0, 0, 0, .35), 0 1px 2px rgba(0, 0, 0, .22);
}
.peca.horizontal .pip { width: 10px; height: 10px; }
.pip.pos-tl { grid-area: 1 / 1; }
.pip.pos-tc { grid-area: 1 / 2; }
.pip.pos-tr { grid-area: 1 / 3; }
.pip.pos-ml { grid-area: 2 / 1; }
.pip.pos-c  { grid-area: 2 / 2; }
.pip.pos-mr { grid-area: 2 / 3; }
.pip.pos-bl { grid-area: 3 / 1; }
.pip.pos-bc { grid-area: 3 / 2; }
.pip.pos-br { grid-area: 3 / 3; }

.mao-pecas {
  display: flex;
  gap: 0;
  justify-content: center;
  flex-wrap: wrap;
  align-items: flex-end;
  padding: 8px 4px 4px;
  min-height: 150px;
}
.mao-pecas .peca {
  width: var(--domino-w);
  height: var(--domino-h);
  flex-direction: column;
  margin-left: -10px;
  transform-origin: bottom center;
}
.mao-pecas .peca:first-child { margin-left: 0; }
.mao-pecas .peca:nth-child(odd) { transform: rotate(-3deg); }
.mao-pecas .peca:nth-child(even) { transform: rotate(3deg); }
.mao-pecas .peca.clicavel:hover {
  transform: translateY(-10px) rotate(0deg) scale(1.03);
  z-index: 5;
}
.mao-pecas .peca.selecionada {
  transform: translateY(-12px) rotate(0deg) scale(1.04) !important;
  z-index: 6;
}
.mao-pecas .peca .peca-lado:first-child { border-bottom: none; border-right: none; }
.peca.jogavel {
  border-color: #00c853;
  box-shadow: 0 0 0 2px rgba(0, 200, 83, .35), 0 10px 22px rgba(0, 200, 83, .28), 0 4px 8px rgba(0, 0, 0, .16);
}
.peca.selecionada {
  border-color: #ffc107;
  box-shadow: 0 0 0 3px rgba(255, 193, 7, .55), 0 12px 26px rgba(255, 193, 7, .32), 0 4px 10px rgba(0, 0, 0, .2);
}

.monte-slot-peca,
.domino-back {
  display: block;
  width: 56px;
  height: 108px;
  border-radius: 10px;
  border: 2px solid #3d342c;
  background:
    radial-gradient(circle at 28% 18%, rgba(255, 255, 255, .45) 0, transparent 42%),
    linear-gradient(165deg, #f5efe4 0%, #ddd2c0 55%, #c9bba8 100%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .75) inset, 0 6px 14px rgba(0, 0, 0, .2), inset 0 -8px 14px rgba(120, 100, 78, .12);
  position: relative;
  overflow: hidden;
}
.monte-slot-peca::before,
.domino-back::before {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 50%;
  width: 3px;
  border-radius: 999px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #8a8074 0%, #5c564e 100%);
  z-index: 2;
}
.monte-slot-peca::after,
.domino-back::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 7px;
  border: 1px dashed rgba(90, 78, 66, .35);
  background: repeating-linear-gradient(45deg, rgba(120, 100, 78, .06) 0 4px, transparent 4px 8px);
  z-index: 1;
}

.modal-compra-overlay,
.modal-resultado-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 5, 0.82);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}
.modal-compra-overlay.aberto,
.modal-resultado-overlay.aberto { display: flex; }
.modal-compra,
.modal-resultado {
  width: min(720px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 28px 24px;
  color: #fff;
  text-align: center;
}
.modal-compra h2,
.modal-resultado h2 {
  font-family: var(--font-display);
  font-style: italic;
  text-transform: uppercase;
  margin: 0 0 8px;
}
.modal-compra p,
.modal-resultado p { color: var(--muted); margin: 0; }
.modal-compra-status { min-height: 24px; margin-top: 10px; font-weight: 700; color: var(--accent); }
.modal-compra-grid {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 14px 12px;
  justify-items: center;
}
.monte-slot {
  appearance: none;
  border: 1px solid var(--line);
  background: #111;
  width: 72px;
  height: 126px;
  padding: 4px;
  margin: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.monte-slot:hover { border-color: var(--accent); }
.monte-slot:disabled { cursor: wait; opacity: 0.6; }
.modal-resultado.vitoria { box-shadow: inset 0 0 0 2px #4ade80; }
.modal-resultado.derrota { box-shadow: inset 0 0 0 2px #e10600; }
.modal-resultado.empate { box-shadow: inset 0 0 0 2px #facc15; }
.resultado-placar { margin-top: 16px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.resultado-cards {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.resultado-card {
  border: 1px solid var(--line);
  background: #000;
  padding: 16px;
  text-align: left;
}
.resultado-card h3 { margin: 0 0 6px; font-size: 0.8rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.resultado-card strong { display: block; font-size: 1.2rem; margin-bottom: 4px; }
.resultado-card small { color: var(--muted); }
.resultado-card.ganhou { box-shadow: inset 3px 0 0 #4ade80; }
.resultado-card.perdeu { box-shadow: inset 3px 0 0 #e10600; }
.resultado-card.empatou { box-shadow: inset 3px 0 0 #facc15; }
.resultado-acao { margin-top: 22px; }

@media (max-width: 860px) {
  .mesa-wrapper { min-height: 280px; padding: 16px 8px; }
  .peca.horizontal { --domino-w: 104px; --domino-h: 52px; }
  .peca.vertical,
  .mao-pecas .peca { --domino-w: 52px; --domino-h: 104px; }
  .pip { width: 9px; height: 9px; }
  .peca.horizontal .pip { width: 8px; height: 8px; }
  .mao-pecas .peca { margin-left: -8px; }
  .resultado-cards { grid-template-columns: 1fr; }
}
