* { box-sizing: border-box; margin: 0; padding: 0; font-family: sans-serif; }

body {
    height: 100vh; 
    height: 100dvh; 
    padding-bottom: 60px !important; /* Ajusta los 60px al tamaño exacto del banner */
    box-sizing: border-box;
    overflow: hidden;
}

.logo-contenedor {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-bottom: 40px; /* Espacio antes de los botones */
    margin-top: 20px;
}

#canvas-logo {
    cursor: pointer; /* Indica que es interactivo */
    max-width: 100%; /* Adaptable a pantallas pequeñas */
}

#app-container {
    display: flex;
    width: 100%;
    height: 100%;
	overflow: hidden;
}

/* ==========================================
   --- 1. PANELES Y LAYOUT GENERAL (PC) ---
   ========================================== */

.panel {
    width: 250px;
    background-color: #ecf0f1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px; 
    border-right: 2px solid #bdc3c7;
    border-left: 2px solid #bdc3c7;
    z-index: 10;
    max-height: 100vh;
}

#panel-central {
    flex-grow: 1; 
    position: relative;
    /* Efecto Madera Realista con CSS Puro */
    background-color: #7d5c3d;
    background-image: 
        repeating-linear-gradient(90deg, rgba(0,0,0,0.03) 0px, rgba(0,0,0,0.03) 1px, transparent 1px, transparent 40px),
        repeating-linear-gradient(180deg, rgba(0,0,0,0.05) 0px, rgba(0,0,0,0.05) 1px, transparent 1px, transparent 2px),
        linear-gradient(90deg, rgba(0,0,0,0.1) 0%, transparent 0.5%, transparent 99.5%, rgba(0,0,0,0.1) 100%);
    background-size: 80px 100%, 100% 2px, 250px 100%;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* --- GRIDS DE RESERVA Y MERCADO (PC) --- */
.grid-ui {
    background-color: rgba(189, 195, 199, 0.3);
    border: 2px inset #bdc3c7;
    padding: 10px;
    border-radius: 8px;
    display: grid;
    gap: 10px;
}

/* RESERVA: 6 huecos fijos que se reparten el alto */
#reserva-grid {
    grid-template-rows: repeat(6, 1fr); 
    flex-grow: 1; 
    min-height: 0;
    overflow: hidden;
}

/* MERCADO: 2 huecos de tamaño fijo */
#mercado-grid {
    grid-template-rows: repeat(2, 100px); 
    flex-grow: 0; 
    place-items: center;    
    margin-bottom: 20px;
}

#reserva-grid .pieza-ui, #mercado-grid .pieza-ui {
    align-self: center;
    margin: 0 auto;
}

/* ==========================================
   --- 2. ELEMENTOS DE UI (Fichas, Botones, Estadísticas) ---
   ========================================== */

.pieza-ui {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #ffffff;
    border-radius: 8px;
    padding: 5px;
    cursor: pointer;
    transition: transform 0.2s, border 0.2s;
    border: 3px solid transparent;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.pieza-ui:hover { transform: scale(1.05); border-color: #3498db; }
.pieza-ui.seleccionada { border-color: #f39c12; background: #fdf5e6; transform: scale(1.05); }

#info-bolsa {
    font-size: 0.9em;
    color: #7f8c8d; 
    margin-top: 5px;
    font-style: italic;
}

.botonera-acciones {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-accion {
    padding: 15px;
    background-color: #f39c12;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
}
.btn-accion:hover { background-color: #e67e22; }

.btn-control {
    transition: opacity 0.3s ease;
    cursor: pointer;
}
.btn-control:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(100%);
}

/* --- CONTROLES DE CÁMARA FLOTANTES --- */
#controles-camara {
    position: absolute;
    bottom: 80px; 
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 50; 
}

#controles-camara button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #bdc3c7;
    background: #ecf0f1;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}
#controles-camara button:active { transform: scale(0.9); }

/* ==========================================
   --- 3. MENÚS Y PANTALLAS ---
   ========================================== */

.capa-menu {
    position: absolute; top: 0; left: 0; width: 100vw; height: 100vh;
    background-color: #2c3e50; color: white;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    z-index: 1000;
}
.capa-menu h1 { font-size: 4rem; margin-bottom: 2rem; }

.boton-grande {
    width: 280px;         /* Ancho fijo para homogeneidad */
    padding: 15px 25px;
    margin: 10px auto;    /* Centrados y con espacio entre ellos */
    font-size: 1.2rem;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    color: white;
    display: block;       /* Uno debajo de otro */
    transition: transform 0.1s, filter 0.2s;
}

.opcion-config {
    margin: 15px 0; display: flex; align-items: center; justify-content: space-between;
    width: 350px; min-height: 40px;
}
.opcion-config label { flex: 1; cursor: pointer; color: white; font-size: 1rem; }
.opcion-config input[type="checkbox"] { width: 25px; height: 25px; margin-right: 10px; cursor: pointer; accent-color: #2ecc71; }

#pantalla-fin {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85); display: none; justify-content: center; align-items: center; z-index: 9999;
}
.contenedor-final {
    background: #1a1a1a; color: white; padding: 2rem; border-radius: 15px; border: 2px solid #e67e22; text-align: center; min-width: 320px;
}

#btn-continuar { 
    background-color: #27ae60 !important; 
    box-shadow: 0 5px #1e8449; 
}
#btn-jugar { 
    background-color: #3498db !important; 
    box-shadow: 0 5px #2980b9; 
}
#btn-abrir-config { 
    background-color: #95a5a6 !important; 
    box-shadow: 0 5px #7f8c8d; 
}

/* Comportamiento al hacer clic para todos */
.boton-grande:active {
    transform: translateY(3px);
    box-shadow: 0 2px rgba(0,0,0,0.2) !important;
}

/* ==========================================
   --- 4. ADAPTACIÓN RESPONSIVE (MÓVILES) ---
   ========================================== */

@media (max-width: 800px) {
    #app-container {
        flex-direction: column !important; /* Apilamos en vertical (Reserva -> Tablero -> Mercado) */
    }

    /* Convertimos los paneles laterales en barras horizontales arriba y abajo */
    .panel {
        width: 100% !important;
        height: 75px !important;       /* Barra fina */
        min-height: 75px !important;
        flex-direction: row !important; /* Elementos de izquierda a derecha */
        padding: 5px 10px !important;
        gap: 10px !important;
        align-items: center;
        border: none !important;
        background-color: #ecf0f1;
    }

    #panel-izquierdo { order: 1; border-bottom: 2px solid #bdc3c7 !important; } /* Arriba */
    
    #panel-central { 
        order: 2; /* En medio */
        flex-grow: 1 !important; /* Ocupa todo el espacio jugable */
    }

    #panel-derecho { 
        order: 3; /* Abajo */
        border-top: 2px solid #bdc3c7 !important; 
        justify-content: space-between; /* Separa mercado de botones */
    }

    /* Ocultamos títulos y estadísticas para ganar espacio */
    .panel h2, #estadisticas { display: none !important; }

    /* Forzamos que las zonas de fichas fluyan en horizontal con scroll si hace falta */
    #reserva-grid, #mercado-grid {
        display: flex !important;
        flex-direction: row !important; /* Fichas apiladas horizontalmente */
        height: 60px !important;
        flex-grow: 1;
        padding: 5px !important;
        margin: 0 !important;
        overflow-x: auto !important; /* Scroll horizontal si hay muchas fichas */
        overflow-y: hidden !important;
        background: transparent !important;
        border: none !important;
        gap: 10px !important;
    }

    /* Fichas un poco más pequeñas */
    .pieza-ui {
        width: 45px !important;
        height: 45px !important;
        flex-shrink: 0; /* Impide que se aplasten */
    }

    /* Botonera en línea y compacta */
    .botonera-acciones {
        flex-direction: row !important;
        gap: 5px !important;
        margin: 0 !important;
    }

    .btn-control {
        height: 45px;
        width: 45px;
        font-size: 1.2rem;
        padding: 0;
    }
}
/* ==========================================
   --- ESTILOS DE LA VENTANA DE REGLAS ---
   ========================================== */
.contenedor-modal {
    background: #ecf0f1;
    padding: 30px;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh; /* Para que no ocupe más del 80% de la altura de la pantalla */
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    border: 3px solid #bdc3c7;
}

.contenido-reglas {
    overflow-y: auto; /* Activa la barra de desplazamiento si el texto es muy largo */
    text-align: left;
    line-height: 1.6;
    padding-right: 15px; /* Espacio para que el texto no se pegue a la barra de scroll */
}

.contenido-reglas h3 {
    margin-top: 20px;
    margin-bottom: 10px;
    color: #2980b9;
    border-bottom: 2px solid #bdc3c7;
    padding-bottom: 5px;
}

.contenido-reglas p, .contenido-reglas ul {
    margin-bottom: 10px;
    font-size: 16px;
    color: #333;
}

.contenido-reglas ul {
    padding-left: 25px;
}