:root {
    --bg-dark: #0f172a;
    --bg-panel: #1e293b;
    --primary: #10b981; /* Verde EDCELL-TECH */
    --primary-hover: #059669;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --piece-bg: #ffffff;
    --piece-dot: #0f172a;
    --danger: #ef4444;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
body { background-color: var(--bg-dark); color: var(--text-main); display: flex; justify-content: center; min-height: 100vh; overflow: hidden; }
#app { width: 100%; max-width: 1200px; position: relative; display: flex; flex-direction: column; }
.screen { display: none; width: 100%; height: 100vh; flex-direction: column; align-items: center; justify-content: center; padding: 20px; }
.screen.active { display: flex; }

/* Menu e UI */
header h1 { font-size: 3rem; color: var(--primary); margin-bottom: 5px; }
header h2 { font-size: 1.2rem; letter-spacing: 2px; margin-bottom: 20px; font-weight: 300; }
.menu-options { display: flex; flex-direction: column; gap: 15px; width: 100%; max-width: 300px; margin-top: 30px; }
button { padding: 12px 20px; background: var(--bg-panel); color: var(--text-main); border: 1px solid var(--primary); border-radius: 8px; font-size: 1rem; cursor: pointer; transition: 0.3s; font-weight: bold; }
button:hover:not(:disabled) { background: var(--primary); color: #fff; }
button.btn-primary { background: var(--primary); }
button:disabled { opacity: 0.5; cursor: not-allowed; border-color: var(--text-muted); }
.config-group { margin-bottom: 20px; width: 100%; max-width: 300px; text-align: left; }
.config-group label { display: block; margin-bottom: 5px; color: var(--primary); }
.config-group input, .config-group select { width: 100%; padding: 10px; background: var(--bg-panel); color: white; border: 1px solid var(--text-muted); border-radius: 5px; }

/* Estrutura do Jogo */
#screen-game { justify-content: space-between; padding: 0; }
.game-header { width: 100%; display: flex; justify-content: space-between; padding: 15px 20px; background: var(--bg-panel); border-bottom: 2px solid var(--primary); }
.player-info { display: flex; flex-direction: column; font-weight: bold; }
.match-info { text-align: right; }
.piece-count { font-size: 0.85rem; color: var(--primary); }

.turn-indicator { padding: 10px; text-align: center; font-weight: bold; background: rgba(16, 185, 129, 0.1); width: 100%; letter-spacing: 1px; transition: 0.3s; }
.turn-ai { color: #f59e0b; background: rgba(245, 158, 11, 0.1); }

.board-container { flex: 1; width: 100%; display: flex; align-items: center; justify-content: center; overflow-x: auto; overflow-y: hidden; padding: 20px; scroll-behavior: smooth; }
.mesa { display: flex; align-items: center; gap: 4px; padding: 20px; min-width: min-content; }

.controls-area { display: flex; justify-content: center; gap: 20px; padding: 10px; }
.player-hand-container { width: 100%; background: var(--bg-panel); padding: 15px; border-top: 2px solid var(--primary); }
.player-info-bottom { display: flex; justify-content: space-between; margin-bottom: 10px; font-weight: bold; }
.mao { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 10px; align-items: center; justify-content: center; }

/* Renderização do Dominó em CSS Puro */
.domino { width: 44px; height: 88px; background: var(--piece-bg); border-radius: 6px; box-shadow: 2px 4px 8px rgba(0,0,0,0.5); display: flex; flex-direction: column; padding: 3px; cursor: pointer; transition: transform 0.2s, opacity 0.3s; user-select: none; flex-shrink: 0; }
.domino:hover { transform: translateY(-5px); }
.domino.disabled { opacity: 0.4; cursor: not-allowed; filter: grayscale(1); }
.domino.disabled:hover { transform: none; }
.domino.horizontal { width: 88px; height: 44px; flex-direction: row; }
.half { flex: 1; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); align-items: center; justify-items: center; }
.domino:not(.horizontal) .half:first-child { border-bottom: 2px solid #ccc; }
.domino.horizontal .half:first-child { border-right: 2px solid #ccc; }

.dot { width: 8px; height: 8px; background: var(--piece-dot); border-radius: 50%; visibility: hidden; }
/* Mapeamento de Pontos via Classes */
.val-1 .d5 { visibility: visible; }
.val-2 .d3, .val-2 .d7 { visibility: visible; }
.val-3 .d3, .val-3 .d5, .val-3 .d7 { visibility: visible; }
.val-4 .d1, .val-4 .d3, .val-4 .d7, .val-4 .d9 { visibility: visible; }
.val-5 .d1, .val-5 .d3, .val-5 .d5, .val-5 .d7, .val-5 .d9 { visibility: visible; }
.val-6 .d1, .val-6 .d2, .val-6 .d3, .val-6 .d7, .val-6 .d8, .val-6 .d9 { visibility: visible; }
.domino.horizontal .val-2 .d3 { grid-area: 1 / 3; } /* Ajustes finos podem ser aplicados se rotacionar a grid, mas a simetria atual já atende o visual */

/* Modais */
#modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); display: flex; justify-content: center; align-items: center; z-index: 100; }
.hidden { display: none !important; }
.modal-box { background: var(--bg-panel); padding: 30px; border-radius: 12px; border: 2px solid var(--primary); text-align: center; max-width: 400px; width: 90%; }
.modal-box h2 { color: var(--primary); margin-bottom: 15px; }
.modal-buttons { margin-top: 20px; display: flex; gap: 10px; justify-content: center; }

/* Responsividade Mobile */
@media (max-width: 768px) {
    .domino { width: 38px; height: 76px; }
    .domino.horizontal { width: 76px; height: 38px; }
    .dot { width: 6px; height: 6px; }
    header h1 { font-size: 2.2rem; }
    .mao { justify-content: flex-start; }
}