/* --- Base y Fuentes --- */

@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&family=Roboto+Mono:wght@300;500&display=swap');

:root {
    --color-bg-dark: #111;
    --color-text-light: #f0f0f0;
    --color-neon-blue: #00f3ff;
    --color-neon-purple: #ff00ff;
    --color-neon-green: #39ff14;
    --color-neon-yellow: #ffff00;
    --color-main-glow: 0 0 5px var(--color-neon-blue), 0 0 10px var(--color-neon-blue);
    --size-casilla: 100px;
    --size-esquina: 120px;
    --grid-size: 8;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Roboto Mono', monospace;
    background-color: var(--color-bg-dark);
    color: var(--color-text-light);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    padding: 10px;
}

/* --- Título y Setup (Modal) --- */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: #1e1e1e;
    padding: 30px;
    border-radius: 10px;
    box-shadow: var(--color-main-glow);
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.setup-box h1 {
    font-family: 'Orbitron', sans-serif;
    color: var(--color-neon-green);
    font-size: 2.5em;
    margin-bottom: 5px;
    text-shadow: 0 0 5px var(--color-neon-green);
}

.setup-box .subtitle {
    font-size: 0.5em;
    display: block;
    color: #c0c0c0;
    margin-bottom: 20px;
}

.setup-section {
    margin: 15px 0;
    font-size: 1.1em;
}

.setup-section select,
.setup-box input[type="text"] {
    background: #333;
    border: 1px solid var(--color-neon-blue);
    color: var(--color-text-light);
    padding: 8px;
    border-radius: 5px;
    width: 100%;
    margin-top: 5px;
    font-family: 'Roboto Mono', monospace;
    transition: box-shadow 0.3s;
}

.setup-box input[type="text"]:focus {
    box-shadow: 0 0 5px var(--color-neon-blue);
    outline: none;
}

#inputs-nombres-container {
    margin-bottom: 20px;
}

.input-nombre-row {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.input-nombre-row label {
    flex-shrink: 0;
    margin-right: 10px;
    width: 30px;
}

.input-nombre-row input {
    flex-grow: 1;
}

.color-preview {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    margin-right: 5px;
    border: 2px solid #333;
}


/* --- Botón Neon (General) --- */

.btn-neon {
    font-family: 'Orbitron', sans-serif;
    background: none;
    border: 2px solid var(--color-neon-blue);
    color: var(--color-neon-blue);
    padding: 10px 20px;
    cursor: pointer;
    text-transform: uppercase;
    transition: background 0.3s, box-shadow 0.3s;
    border-radius: 5px;
    box-shadow: var(--color-main-glow);
    margin-top: 15px;
}

.btn-neon:hover {
    background: rgba(0, 243, 255, 0.2);
    box-shadow: 0 0 10px var(--color-neon-blue), 0 0 20px var(--color-neon-blue);
}

.btn-neon:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
    background: #333;
    border-color: #555;
    color: #888;
}

.big-btn {
    font-size: 1.2em;
    padding: 15px 30px;
}


/* --- Layout Principal del Juego --- */

#juego-main {
    display: flex;
    gap: 20px;
    max-width: 1200px;
    width: 100%;
}

.oculto {
    display: none !important;
}

/* --- Tablero --- */

#tablero-grid {
    display: grid;
    /* Las esquinas son más grandes: 120px + 6 * 100px + 120px = 840px de ancho total en PC */
    grid-template-columns: var(--size-esquina) repeat(6, var(--size-casilla)) var(--size-esquina);
    grid-template-rows: var(--size-esquina) repeat(6, var(--size-casilla)) var(--size-esquina);
    
    border: 5px solid #444;
    position: relative;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
}

.casilla {
    background-color: #222;
    border: 1px solid #444;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    position: relative;
    overflow: hidden;
    text-align: center;
}

/* Esquinas */
.casilla.esquina {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2em;
    font-weight: bold;
    font-family: 'Orbitron', sans-serif;
    color: var(--color-neon-purple);
    background-color: #333;
    text-shadow: 0 0 5px var(--color-neon-purple);
}

/* AJUSTE CLAVE: Reducción de fuentes para asegurar que el texto quepa */
.casilla-content {
    padding: 3px 5px; /* Reducir padding vertical */
    font-size: 0.65em; /* Reducir fuente base de la casilla */
    width: 100%;
    flex-grow: 1; /* Permite que el contenido se estire un poco más */
    display: flex;
    flex-direction: column;
    justify-content: space-around;
}

.propiedad-header {
    height: 15px;
    width: 100%;
    flex-shrink: 0;
}

.c-nombre {
    font-size: 1em; /* 0.65em * 1em = 0.65em */
    font-weight: bold;
    line-height: 1;
    margin-top: 2px;
}

.c-precio {
    color: var(--color-neon-yellow);
    margin: 1px 0;
    font-size: 1.1em; /* Más prominente */
}

.c-renta, .c-propietario {
    font-size: 1em;
    color: #ccc;
    line-height: 1.1;
}

.owner-indicator {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background-color: transparent;
    transition: background-color 0.5s;
    opacity: 0;
}

/* Centro del Tablero */
.tablero-centro {
    grid-column: 2 / 8;
    grid-row: 2 / 8;
    background-color: #1e1e1e;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-family: 'Orbitron', sans-serif;
    padding: 20px;
    text-align: center;
}

.tablero-centro h2 {
    color: var(--color-neon-green);
    font-size: 2em;
    margin-bottom: 10px;
}

#mensaje-sistema {
    font-size: 1.1em;
    color: var(--color-neon-blue);
    min-height: 30px;
    margin-top: 10px;
}


/* --- Fichas de Jugadores --- */

.fichas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    justify-content: flex-start;
    padding: 5px;
    gap: 2px;
    z-index: 10;
}

.ficha-tablero {
    width: 12px; /* Ligeramente más grande para PC */
    height: 12px;
    border-radius: 50%;
    border: 1px solid #000;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
    transition: transform 0.3s;
}

/* Ajuste de posición de fichas en esquinas para mejor visibilidad */
.casilla.esquina .fichas-container {
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
    gap: 5px;
}

.casilla.esquina .ficha-tablero {
    width: 15px;
    height: 15px;
}

/* --- Panel de Jugadores (PC) --- */

#panel-jugadores {
    width: 250px;
    background-color: #1e1e1e;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    flex-shrink: 0;
}

#panel-jugadores h3 {
    font-family: 'Orbitron', sans-serif;
    color: var(--color-neon-blue);
    text-align: center;
    margin-bottom: 15px;
    text-shadow: var(--color-main-glow);
}

.jugador-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 5px;
    border-bottom: 1px dashed #333;
    transition: background-color 0.3s;
}

.jugador-item:last-child {
    border-bottom: none;
}

.turno-activo {
    background-color: rgba(0, 243, 255, 0.1);
    border: 1px solid var(--color-neon-blue);
    border-radius: 5px;
    box-shadow: 0 0 3px var(--color-neon-blue);
    padding: 10px 8px;
}

.j-nombre {
    font-weight: bold;
    display: flex;
    align-items: center;
}

.j-dinero {
    color: var(--color-neon-green);
    font-weight: bold;
}


/* --- Dado y Controles (PC) --- */

#controles-pc {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 20px;
    padding: 15px;
    background-color: #2a2a2a;
    border-radius: 8px;
}

#turno-info-pc {
    margin-bottom: 10px;
    font-size: 1.1em;
}

#turno-nombre-pc {
    font-family: 'Orbitron', sans-serif;
    color: var(--color-neon-yellow);
    text-shadow: 0 0 5px var(--color-neon-yellow);
}

/* --- Dado 3D General --- */

.dice-container {
    perspective: 800px;
    margin: 20px 0;
    width: 100px;
    height: 100px;
}

#dado3d, #dado3d-pc {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    /* El estado inicial es el 1 al frente (cara 1: 0deg, 0deg) */
    transform: translateZ(-50px) rotateX(0deg) rotateY(0deg); 
}

.cube__face {
    position: absolute;
    width: 100px;
    height: 100px;
    border: 2px solid #333;
    line-height: 96px;
    font-size: 40px;
    font-weight: bold;
    color: var(--color-bg-dark);
    text-align: center;
    background: var(--color-text-light);
    border-radius: 10px;
}

/* Transformaciones para que la cara quede al frente */
/* Nota: La cara 1 mira hacia el Z positivo. */
.cube__face--1 { transform: rotateY(0deg) translateZ(50px); }
.cube__face--6 { transform: rotateX(180deg) translateZ(50px); } /* Anteriormente rotateY(180deg), ajustado para coincidir con la rotación del 6 */
.cube__face--3 { transform: rotateY(90deg) translateZ(50px); }
.cube__face--4 { transform: rotateY(-90deg) translateZ(50px); }
.cube__face--5 { transform: rotateX(90deg) translateZ(50px); }
.cube__face--2 { transform: rotateX(-90deg) translateZ(50px); }

/* Puntos del dado - (Se mantienen sin cambios) */
.dot {
    position: absolute;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: var(--color-bg-dark);
}
.cube__face--1 .dot { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.cube__face--2 .dot:nth-child(1) { top: 20%; left: 20%; }
.cube__face--2 .dot:nth-child(2) { bottom: 20%; right: 20%; }
.cube__face--3 .dot:nth-child(1) { top: 20%; left: 20%; }
.cube__face--3 .dot:nth-child(2) { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.cube__face--3 .dot:nth-child(3) { bottom: 20%; right: 20%; }
.cube__face--4 .dot:nth-child(1) { top: 20%; left: 20%; }
.cube__face--4 .dot:nth-child(2) { top: 20%; right: 20%; }
.cube__face--4 .dot:nth-child(3) { bottom: 20%; left: 20%; }
.cube__face--4 .dot:nth-child(4) { bottom: 20%; right: 20%; }
.cube__face--5 .dot:nth-child(1) { top: 20%; left: 20%; }
.cube__face--5 .dot:nth-child(2) { top: 20%; right: 20%; }
.cube__face--5 .dot:nth-child(3) { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.cube__face--5 .dot:nth-child(4) { bottom: 20%; left: 20%; }
.cube__face--5 .dot:nth-child(5) { bottom: 20%; right: 20%; }
.cube__face--6 .dot:nth-child(1) { top: 20%; left: 20%; }
.cube__face--6 .dot:nth-child(2) { top: 20%; right: 20%; }
.cube__face--6 .dot:nth-child(3) { top: 50%; left: 20%; transform: translateY(-50%); }
.cube__face--6 .dot:nth-child(4) { top: 50%; right: 20%; transform: translateY(-50%); }
.cube__face--6 .dot:nth-child(5) { bottom: 20%; left: 20%; }
.cube__face--6 .dot:nth-child(6) { bottom: 20%; right: 20%; }


/* Indicador de resultado */
#resultado-dado-pc {
    margin-top: 15px;
    font-size: 1.2em;
    font-weight: bold;
    color: var(--color-neon-green);
}

/* --- Controles Móviles --- */

#controles-movil {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: #1a1a1a;
    box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.5);
    padding: 10px;
    display: none; /* Por defecto oculto en PC */
    flex-direction: column;
    align-items: center;
    z-index: 50;
}

#btn-movil-jugadores {
    display: none; /* Se muestra solo en modo móvil */
}

/* --- Responsive (Modo Móvil) --- */

@media (max-width: 800px) {
    
    :root {
        --size-casilla: 60px;
        --size-esquina: 80px;
    }

    body {
        padding: 5px;
        align-items: flex-start;
    }

    #juego-main {
        flex-direction: column;
        gap: 10px;
        width: 100%;
        max-width: 100%;
    }

    /* Tablero */
    #tablero-grid {
        width: 100vw;
        height: 100vw;
        max-width: calc(var(--size-esquina) + 6 * var(--size-casilla));
        max-height: calc(var(--size-esquina) + 6 * var(--size-casilla));
        margin: 0 auto;
    }

    /* AJUSTE CLAVE MÓVIL: Reducción de fuente en casillas */
    .casilla-content {
        padding: 2px 3px; 
        font-size: 0.6em; 
    }

    .c-nombre {
        font-size: 0.9em;
    }

    .c-precio, .c-renta, .c-propietario {
        font-size: 0.9em;
    }

    .propiedad-header {
        height: 10px;
    }

    .ficha-tablero {
        width: 8px;
        height: 8px;
    }

    /* Controles */
    #controles-pc {
        display: none;
    }

    #controles-movil {
        display: flex;
    }

    .dice-container {
        width: 80px;
        height: 80px;
        margin: 5px 0;
        perspective: 500px;
    }
    
    #dado3d {
         width: 80px;
         height: 80px;
         transform: translateZ(-40px) rotateX(0deg) rotateY(0deg); 
    }

    .cube__face {
        width: 80px;
        height: 80px;
        line-height: 76px;
        font-size: 30px;
        border-radius: 8px;
    }

    .cube__face--1 { transform: rotateY(0deg) translateZ(40px); }
    .cube__face--6 { transform: rotateX(180deg) translateZ(40px); }
    .cube__face--3 { transform: rotateY(90deg) translateZ(40px); }
    .cube__face--4 { transform: rotateY(-90deg) translateZ(40px); }
    .cube__face--5 { transform: rotateX(90deg) translateZ(40px); }
    .cube__face--2 { transform: rotateX(-90deg) translateZ(40px); }

    .dot {
        width: 10px;
        height: 10px;
    }

    #resultado-dado {
        font-size: 1em;
        margin-bottom: 10px;
    }

    #controles-movil .btn-neon {
        margin: 5px 0;
        padding: 8px 15px;
        font-size: 1em;
    }
    
    #btn-movil-jugadores {
        display: inline-block;
        position: fixed;
        top: 10px;
        right: 10px;
        z-index: 60;
        border-color: var(--color-neon-purple);
        color: var(--color-neon-purple);
        box-shadow: 0 0 5px var(--color-neon-purple);
    }
    
    /* Panel de Jugadores Móvil */
    #panel-jugadores {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        transform: translateX(100%);
        transition: transform 0.3s ease-out;
        z-index: 90;
        overflow-y: auto;
        border-radius: 0;
    }
    
    #panel-jugadores.visible {
        transform: translateX(0);
    }
    
    #panel-jugadores h3 {
        padding-top: 20px;
    }
}