/* Configurações Globais e Reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    user-select: none;
}

body {
    background-color: #eef2f7;
    color: #333;
    overflow: hidden;
}

/* CONTAINER INTELIGENTE */
#game-container {
    width: 100%;
    margin: 0 auto;
    height: 100vh;
    padding: 10px;
    display: flex;
    flex-direction: column;
}

/* Se for Computador/Monitor (Telas maiores que 600px) - Intocado */
@media (min-width: 600px) {
    #game-container {
        max-width: 550px; 
        padding: 20px;
    }
    .control-btn {
        flex-direction: row !important; 
        gap: 8px;
        font-size: 14px !important;
    }
}

/* Se for Celular/Mobile (Telas pequenas) - Ajustado Largura, Botões e ESCALA DO JOGO */
@media (max-width: 599px) {
    #game-container {
        max-width: 390px; /* ENGORDADO NA LARGURA: Dá espaço lateral para os botões */
        max-height: 85vh; 
    }
    .control-btn {
        flex-direction: row !important; /* Coloca ícone/texto lado a lado para não espremer */
        gap: 4px;
        font-size: 12px !important; /* Tamanho ideal para leitura rápida no celular */
    }
    
    /* APLICA A ESCALA EXCLUSIVAMENTE NO MOBILE */
    #board {
        transform: scale(1.25);        /* Cresce 25% apenas no celular. Se achar muito, mude para 1.2 */
        transform-origin: center top;  /* Garante o crescimento correto a partir do topo */
        margin-top: 25px;              /* Afastamento do topo para acomodar o tamanho maior */
    }
}

/* Cabeçalho Compacto */
#game-header {
    height: 50px;
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    padding: 8px 12px;
    margin-bottom: 8px;
}

.qi-display { float: left; }
.qi-label { display: block; font-size: 10px; color: #7f8c8d; font-weight: bold; }
#qi-value { font-size: 20px; font-weight: 800; color: #2c3e50; line-height: 1; }
.level-display { float: right; font-size: 14px; margin-top: 6px; color: #34495e; }

/* Área do Tabuleiro Centralizado */
#board-container {
    flex: 1;
    background: #f8fafc;
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center; 
}

/* Tabuleiro Base - Padrão e Travado para o Computador */
#board {
    position: relative;
    width: 263px; 
    height: 100%;
}

/* ESTEIRA DE DEPÓSITO */
#slot-container {
    height: 78px;
    background: #cbd5e1;
    border: 2px solid #94a3b8;
    border-radius: 10px;
    margin-top: 8px;
    margin-bottom: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 4px;
}

.slot-space {
    width: 44px;
    height: 62px;
    border: 2px dashed #64748b;
    border-radius: 5px;
    position: relative;
}

/* PEÇAS ESTILO DOMINÓ 3D */
.tile {
    position: absolute;
    width: 44px;
    height: 62px;
    background-color: #ffffff;
    border-radius: 5px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
    display: table;
    text-align: center;
    border-top: 1px solid #e2e8f0;
    border-left: 1px solid #e2e8f0;
    box-shadow: 
        1px 1px 0px #cbd5e1,
        2px 2px 0px #cbd5e1,
        3px 3px 0px #94a3b8,
        3px 3px 4px rgba(0, 0, 0, 0.15);
}

.tile-content {
    display: table-cell;
    vertical-align: middle;
    font-size: 20px;
    font-weight: bold;
    color: #ffffff;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.5);
    border-radius: 3px;
}

.tile-border-blue { border: 2.5px solid #3b82f6; }
.tile-border-yellow { border: 2.5px solid #eab308; }
.tile-border-green { border: 2.5px solid #22c55e; }
.tile-border-red { border: 2.5px solid #ef4444; }
.tile-border-purple { border: 2.5px solid #a855f7; }

.tile.in-slot {
    position: static !important;
    transform: none !important;
    box-shadow: 1px 1px 2px rgba(0,0,0,0.1) !important;
}

.tile.hinted { animation: pulse-hint 0.5s infinite alternate; }
@keyframes pulse-hint {
    0% { box-shadow: 0 0 3px 3px #000000; filter: brightness(1.3); }
    100% { box-shadow: 0 0 12px 4px #000000; filter: brightness(0.7); }
}

/* Barra de Botões Adaptável */
#game-controls {
    height: 52px;
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.control-btn {
    flex: 1;
    height: 100%;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}

.control-btn:hover { background: #f8fafc; }

/* Modais de Tela Inteira Restaurados */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.modal.hide { display: none !important; }

.modal-content {
    background: #ffffff;
    width: 88%;
    max-width: 360px;
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}

.modal-content h2 { color: #1e3a8a; font-size: 24px; margin-bottom: 6px; letter-spacing: 1px; }
.modal-content p { color: #64748b; font-size: 14px; margin-bottom: 14px; }

.stats-box {
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 16px;
}
.stat-item { margin: 8px 0; text-align: left; font-size: 14px; color: #475569;}
.stat-highlight { float: right; font-weight: bold; color: #2563eb; }
.performance-text { font-size: 14px; color: #0f172a; margin-bottom: 16px !important; }

.action-btn { width: 100%; padding: 12px 0; background: #2563eb; color: #ffffff; font-size: 15px; font-weight: bold; border: none; border-radius: 8px; cursor: pointer; margin-top: 4px; }
.action-btn:hover { background: #1d4ed8; }
.secondary-btn { background: #64748b; }