/* ========================================================
   MESA DIGITAL - ESTILOS GERAIS E DAS PEDRAS DE DOMINÓ
   KS Studio
   ======================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700;800;900&display=swap');

:root {
  --table-felt: #0c3823;
  --table-felt-dark: #061c11;
  --table-border: #3b2210;
  --gold: #f59e0b;
  --gold-light: #fbbf24;
  --domino-bg: #faf7f2;
  --domino-border: #dcd6cc;
  --domino-shadow: rgba(0, 0, 0, 0.45);
  --pip-color: #1a1a1a;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
  background-color: #0b0f19;
  color: #f8fafc;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  overscroll-behavior: none;
}

/* ----------------------------------------------------
   PEDRA DE DOMINÓ REALISTA (BONE / IVORY 3D)
   ---------------------------------------------------- */
.domino-tile {
  background: linear-gradient(145deg, #ffffff 0%, #f3eee3 60%, #e2d9c8 100%);
  border-radius: 8px;
  box-shadow: 
    0 4px 10px var(--domino-shadow),
    0 1px 3px rgba(0,0,0,0.3),
    inset 0 1px 1px rgba(255,255,255,0.9),
    inset 0 -1px 2px rgba(0,0,0,0.25);
  border: 1px solid var(--domino-border);
  position: relative;
  display: flex;
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.18s ease;
  cursor: pointer;
  flex-shrink: 0;
}

/* Efeito de pedra na mão no celular */
.domino-tile.in-hand {
  width: 48px;
  height: 88px;
  flex-direction: column;
}

@media (max-width: 380px) {
  .domino-tile.in-hand {
    width: 42px;
    height: 78px;
    border-radius: 6px;
  }
}

/* Pedra horizontal (na corrente da mesa) */
.domino-tile.horizontal {
  width: 72px;
  height: 40px;
  flex-direction: row;
}

/* Pedra vertical / Bucha atravessada */
.domino-tile.vertical {
  width: 40px;
  height: 72px;
  flex-direction: column;
}

@media (max-width: 600px) {
  .domino-tile.horizontal {
    width: 58px;
    height: 32px;
  }
  .domino-tile.vertical {
    width: 32px;
    height: 58px;
  }
}

/* Pedra MINI (para a prévia da mesa no celular do jogador) */
.domino-tile.mini {
  width: 42px;
  height: 24px;
  flex-direction: row;
  border-radius: 4px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.4);
}

.domino-tile.mini.vertical {
  width: 24px;
  height: 42px;
  flex-direction: column;
}

.domino-tile.mini .pip {
  width: 4px;
  height: 4px;
}

.domino-tile.mini .tile-half {
  padding: 1px;
}

/* Divisor central da pedra com o pino de metal no meio (Spinner) */
.domino-tile.in-hand .tile-divider,
.domino-tile.vertical .tile-divider {
  width: 84%;
  height: 2px;
  background: #a89f91;
  margin: 0 auto;
  position: relative;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}

.domino-tile.horizontal .tile-divider,
.domino-tile.mini:not(.vertical) .tile-divider {
  height: 84%;
  width: 2px;
  background: #a89f91;
  margin: auto 0;
  position: relative;
  box-shadow: 1px 0 0 rgba(255, 255, 255, 0.7);
}

/* Pino de latão central (spinner rivet clássico) */
.tile-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 4px;
  height: 4px;
  background: radial-gradient(circle, #e6b800 20%, #8a6500 90%);
  border-radius: 50%;
  box-shadow: 0 0 2px rgba(0,0,0,0.5);
}

/* Metades da pedra */
.tile-half {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 3px;
  align-items: center;
  justify-items: center;
}

/* Os pontos pretos (PIPS) */
.pip {
  width: 6px;
  height: 6px;
  background: radial-gradient(circle at 35% 35%, #333333, #0a0a0a);
  border-radius: 50%;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.8), 0 1px 0 rgba(255,255,255,0.4);
}

@media (max-width: 380px) {
  .pip {
    width: 5px;
    height: 5px;
  }
}

/* Posições dos pontos na matriz 3x3 */
.pos-tl { grid-column: 1; grid-row: 1; }
.pos-tc { grid-column: 2; grid-row: 1; }
.pos-tr { grid-column: 3; grid-row: 1; }
.pos-ml { grid-column: 1; grid-row: 2; }
.pos-mc { grid-column: 2; grid-row: 2; }
.pos-mr { grid-column: 3; grid-row: 2; }
.pos-bl { grid-column: 1; grid-row: 3; }
.pos-bc { grid-column: 2; grid-row: 3; }
.pos-br { grid-column: 3; grid-row: 3; }

/* Destaque para pedras jogáveis */
.domino-tile.playable {
  box-shadow: 
    0 0 0 3px #10b981, 
    0 6px 18px rgba(16, 185, 129, 0.45),
    inset 0 1px 1px rgba(255,255,255,0.9);
  animation: pulse-playable 2s infinite ease-in-out;
  cursor: pointer;
}

.domino-tile.playable:active {
  transform: scale(0.95) translateY(-3px);
}

/* Tag indicadora de onde a pedra encaixa (Esq / Dir / Ambos) */
.playable-side-tag {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: #059669;
  color: white;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 6px;
  white-space: nowrap;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  z-index: 20;
}

@keyframes pulse-playable {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* Pedras não jogáveis (esmaecidas) */
.domino-tile.disabled {
  opacity: 0.45;
  filter: grayscale(0.3);
  cursor: not-allowed;
}

/* ----------------------------------------------------
   BOTÕES E COMPONENTES MODERNOS COM FOCO EM TOUCH
   ---------------------------------------------------- */
.btn-primary {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  padding: 12px 20px;
  min-height: 48px;
  font-size: 0.95rem;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary:active {
  transform: scale(0.97);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-warning {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #1a1a1a;
  font-weight: 800;
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  min-height: 48px;
  font-size: 0.95rem;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-warning:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background: #1e293b;
  color: #e2e8f0;
  font-weight: 600;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 10px 16px;
  min-height: 48px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Modal Popup */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal-card {
  background: #111827;
  border: 1px solid #374151;
  border-radius: 20px;
  padding: 24px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  text-align: center;
  animation: modal-pop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modal-pop {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
