/* ============================================================================
   MULINO (Nine Men's Morris) - Stili CSS
   Stile feltro verde Burraco/Scopa con layout 1024x750px, coerente con la Dama
   ============================================================================ */

/* === BASE & LAYOUT === */
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #1a5f2a;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.main-container {
    position: relative;
    width: 100%;
    height: 100%;
}

/* === SIDEBARS (per AdSense e layout) === */
.sidebar {
    position: absolute;
    top: 0;
    height: 100%;
    background: linear-gradient(135deg, #1a6b30 0%, #145524 50%, #0f4a1c 100%);
    overflow-y: auto;
    box-sizing: border-box;
    display: none;
    flex-direction: column;
    align-items: center;
    z-index: 1;
    transition: opacity 0.3s ease;
}
#sidebar-left { left: 0; }
#sidebar-right { right: 0; }

/* === CAMPO DI GIOCO === */
#campogioco {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1024px;
    height: 750px;
    background: linear-gradient(135deg, #1a6b30 0%, #145524 50%, #0f4a1c 100%);
    background-image: url(images/scala40/tappetoverde.png);
    transform-origin: center center;
    border-radius: 10px;
    box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0,0,0,0.5);
    overflow: hidden;
}

/* === SCHERMO OVERLAY === */
#schermo {
    position: absolute;
    top: 0;
    left: 0;
    width: 1024px;
    height: 750px;
    background-color: rgba(0, 0, 0, 0.65);
    z-index: 30000;
    display: none;
}

/* === TITOLO E BARRA SUPERIORE === */
#titolo-gioco {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    color: #ffd700;
    font-size: 26px;
    font-family: 'Slackey', 'Outfit', sans-serif;
    font-weight: bold;
    z-index: 1000;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
    white-space: nowrap;
}

#messaggio-stato {
    position: absolute;
    top: 50px;
    left: 340px;
    transform: translateX(-50%);
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    background: rgba(0, 40, 10, 0.6);
    padding: 6px 20px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 100;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    white-space: normal;
    max-width: 560px;
    width: max-content;
    line-height: 1.35;
    transition: background-color 0.2s, color 0.2s;
}
#messaggio-stato.msg-giallo {
    background: #ffd700;
    color: #1a1a2e;
    border-color: #b8860b;
    text-shadow: none;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}
#messaggio-stato.msg-rosso {
    background: #cc0c39;
    color: #fff;
    border-color: #990022;
    text-shadow: none;
    box-shadow: 0 0 15px rgba(204, 12, 57, 0.5);
}

.lang-switch-header {
    position: absolute;
    top: 8px;
    right: 15px;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 10001;
}
/* I selettori di lingua stanno nella barra in alto a sinistra, subito a destra
   di "Come si Gioca"; nell'angolo destro resta la sola icona audio. */
.lang-switch-inline {
    display: flex;
    align-items: center;
    gap: 6px;
}

.lang-switch-header a,
.lang-switch-inline a {
    height: 26px;
    line-height: 26px;
    background: rgba(0,0,0,0.4);
    border: 1px solid #6b9b7a;
    color: white;
    border-radius: 4px;
    padding: 0 10px;
    cursor: pointer;
    font-size: 11px;
    font-weight: bold;
    text-decoration: none;
    transition: all 0.2s;
    box-sizing: border-box;
}
.lang-switch-header a.active,
.lang-switch-inline a.active {
    background: linear-gradient(180deg, #ffd700 0%, #d4af37 100%);
    color: #1a1a2e;
    border-color: #b8860b;
}
.lang-switch-header a:hover:not(.active),
.lang-switch-inline a:hover:not(.active) {
    background: rgba(0, 60, 20, 0.7);
    border-color: rgba(255, 255, 255, 0.5);
}

.btn-audio-game {
    width: 26px;
    height: 26px;
    cursor: pointer;
}

.pulsante-top {
    height: 26px;
    line-height: 26px;
    background: rgba(0,0,0,0.4);
    border: 1px solid #6b9b7a;
    color: white;
    border-radius: 4px;
    padding: 0 10px;
    cursor: pointer;
    font-size: 11px;
    font-weight: bold;
    text-decoration: none;
    transition: all 0.2s;
    box-sizing: border-box;
}
.pulsante-top:hover {
    background: rgba(0, 60, 20, 0.7);
    border-color: rgba(255, 255, 255, 0.5);
}

.link-utility-bottom {
    position: absolute;
    top: 8px;
    left: 15px;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 10001;
}

/* === PANNELLO STATISTICHE (in alto a destra) === */
#pannello-stats {
    position: absolute;
    top: 10px;
    left: 680px;
    width: 290px;
    z-index: 50;
    background: rgba(0, 40, 10, 0.55);
    border: 2px solid rgba(100, 160, 110, 0.35);
    border-radius: 10px;
    padding: 8px 14px 10px;
    box-sizing: border-box;
    color: #fff;
}
.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    font-weight: bold;
    color: #aed6ae;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}
#btn-reset-stats {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #ccc;
    border-radius: 4px;
    font-size: 11px;
    line-height: 1;
    padding: 2px 8px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 32px;
}
#btn-reset-stats:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.5);
}
#btn-reset-stats.conferma {
    background: #cc0c39;
    color: #fff;
    border-color: #990022;
    font-weight: bold;
}
.stats-righe {
    display: flex;
    justify-content: space-between;
}
.stats-righe .info-blocco {
    text-align: center;
    flex: 1;
}
.stats-righe .info-label {
    font-size: 11px;
    color: #aed6ae;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.stat-valore {
    font-size: 18px;
    font-weight: bold;
    color: #7fd4ff;
    margin-top: 2px;
}
#stat-vinte { color: #7fe07f; }
#stat-perse { color: #ff8f8f; }

/* === TABELLONE ===
   Non è una griglia di caselle: 24 nodi in coordinate assolute, con le linee
   disegnate come sottili div sotto ai nodi.
   560 = 420px di area utile + 62px di cornice per lato + 8px di bordo per lato
   (box-sizing: border-box, quindi l'area interna netta è esattamente 544).
   Cornice e bordo sommano a 70px, cioè un passo di griglia (420/6): lo stacco
   fra il legno e il primo quadrato è così identico a quello fra due quadrati
   concentrici. Cambiando il border-width va aggiornato BORDO_TAB nel JS.
   La cornice è nelle
   coordinate calcolate dal JS (MARGINE_TAB), non in un padding: i figli
   assoluti si riferiscono al padding box, quindi un padding non li
   scosterebbe dal bordo in alto e a sinistra e il disegno risulterebbe
   scentrato verso quell'angolo. */
#tabellone {
    position: absolute;
    top: 122px;
    left: 60px;      /* centrato nella colonna di gioco larga 680: (680-560)/2 */
    width: 560px;
    height: 560px;
    box-sizing: border-box;
    background: #9c6b3c;
    background-image: linear-gradient(135deg, rgba(255,255,255,0.06) 0%, rgba(0,0,0,0.12) 100%);
    border: 8px solid #4a2f17;
    border-radius: 8px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.55), inset 0 0 12px rgba(0,0,0,0.4);
    z-index: 50;
}

/* Segmenti che uniscono i punti: left/top/width/height li assegna il JS, che
   include già MARGINE_TAB nelle coordinate. */
.linea {
    position: absolute;
    background: #4a2f17;
    border-radius: 2px;
    pointer-events: none;
    box-shadow: 0 1px 1px rgba(255,255,255,0.12);
}

/* Nodi: cerchietti cliccabili da centrare sulla propria coordinata.
   Il JS assegna left/top del punto esatto, i margini negativi di mezza
   larghezza spostano il cerchio in modo che risulti centrato lì sopra. */
.nodo {
    position: absolute;
    width: 48px;
    height: 48px;
    margin-left: -24px;
    margin-top: -24px;
    border-radius: 50%;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 5;
}
/* Punto di innesto visibile quando la posizione è vuota */
.nodo::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #6b4423;
    border: 2px solid #3d2612;
    box-sizing: border-box;
    pointer-events: none;
}
.nodo:has(.pezzo)::before { display: none; }

/* Evidenziazioni di gioco */
.nodo.selezionabile::after {
    content: '';
    position: absolute;
    inset: 2px;
    border: 3px solid rgba(255, 215, 0, 0.6);
    border-radius: 50%;
    pointer-events: none;
}
.nodo.selezionata::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 4px solid #ffd700;
    border-radius: 50%;
    box-shadow: 0 0 16px rgba(255, 215, 0, 0.9);
    pointer-events: none;
}
.nodo.destinazione::after {
    content: '';
    position: absolute;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255, 215, 0, 0.55);
    border: 3px solid rgba(255, 215, 0, 0.9);
    box-sizing: border-box;
    animation: pulsaDest 0.9s infinite;
    pointer-events: none;
}
@keyframes pulsaDest {
    0%, 100% { transform: scale(1); opacity: 0.85; }
    50% { transform: scale(1.25); opacity: 1; }
}
.nodo.suggerita::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 4px solid #7fd4ff;
    border-radius: 50%;
    box-shadow: 0 0 18px 3px rgba(127, 212, 255, 0.9);
    pointer-events: none;
}
/* Pedine avversarie che si possono togliere dopo un mulino */
.nodo.catturabile::after {
    content: '\00D7';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    font-weight: bold;
    color: #ff3b3b;
    text-shadow: 0 0 6px rgba(0,0,0,0.9);
    border: 4px solid #ff3b3b;
    border-radius: 50%;
    box-sizing: border-box;
    animation: pulsaDest 0.9s infinite;
    pointer-events: none;
}

/* === PEDINE === */
.pezzo {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    box-sizing: border-box;
    position: relative;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.45);
}
.pezzo.bianco {
    background: radial-gradient(circle at 35% 30%, #fffdf5 0%, #f0e6c8 45%, #cdbd92 100%);
    border: 3px solid #b3a27a;
}
.pezzo.nero {
    background: radial-gradient(circle at 35% 30%, #6a6a6a 0%, #3a3a3a 45%, #191919 100%);
    border: 3px solid #000;
}
/* Anello interno per l'effetto "pedina tornita" */
.pezzo::before {
    content: '';
    position: absolute;
    inset: 6px;
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, 0.18);
    pointer-events: none;
}
.pezzo.nero::before { border-color: rgba(255, 255, 255, 0.15); }
/* Pedina che fa parte di un mulino chiuso */
.pezzo.in-mulino {
    box-shadow: 0 4px 8px rgba(0,0,0,0.45), 0 0 0 3px rgba(255, 215, 0, 0.85);
}

/* === RISERVE (pedine ancora da piazzare) === */
.riserva {
    position: absolute;
    left: 60px;       /* allineata al bordo sinistro del tabellone */
    width: 560px;
    height: 26px;
    display: flex;
    gap: 5px;
    align-items: center;
    z-index: 50;
}
#riserva-computer { top: 84px; }
#riserva-giocatore { top: 690px; }   /* sotto il tabellone: 122 + 560 = 682 */

.pezzo-riserva {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    box-sizing: border-box;
    box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}
.pezzo-riserva.bianco {
    background: radial-gradient(circle at 35% 30%, #fffdf5 0%, #f0e6c8 45%, #cdbd92 100%);
    border: 2px solid #b3a27a;
}
.pezzo-riserva.nero {
    background: radial-gradient(circle at 35% 30%, #6a6a6a 0%, #3a3a3a 45%, #191919 100%);
    border: 2px solid #000;
}

/* === PANNELLO CONTROLLI (colonna destra) === */
#pannello-controlli {
    position: absolute;
    top: 108px;
    left: 680px;
    width: 290px;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#info-partita {
    background: rgba(0, 40, 10, 0.55);
    border: 2px solid rgba(100, 160, 110, 0.35);
    border-radius: 10px;
    padding: 10px 14px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px 0;
    color: #fff;
    font-size: 14px;
}
#info-partita .info-blocco {
    text-align: center;
    flex: 1 0 33%;
}
#info-partita .info-label {
    font-size: 11px;
    color: #aed6ae;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
#info-partita .info-valore {
    font-size: 17px;
    font-weight: bold;
    color: #ffd700;
    margin-top: 2px;
}

#azioni {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}
.btn-azione {
    height: 46px;
    font-size: 13px;
    font-weight: bold;
    color: white;
    background: rgba(0, 40, 10, 0.6);
    border: 2px solid #6b9b7a;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    text-transform: uppercase;
}
.btn-azione:hover:not(:disabled) {
    background: rgba(0, 60, 20, 0.8);
    border-color: rgba(255, 255, 255, 0.5);
}
.btn-azione:disabled {
    opacity: 0.4;
    cursor: default;
}

/* Legenda breve delle regole principali */
#promemoria-regole {
    background: rgba(0, 40, 10, 0.55);
    border: 2px solid rgba(100, 160, 110, 0.35);
    border-radius: 10px;
    padding: 10px 14px;
    color: #cde8cd;
    font-size: 12px;
    line-height: 1.55;
}
#promemoria-regole b { color: #ffd700; }

#btn-nuova-partita {
    height: 56px;
    font-size: 18px;
    font-weight: bold;
    font-family: 'Slackey', 'Outfit', sans-serif;
    color: #1a1a2e;
    background: linear-gradient(180deg, #ffd700 0%, #d4af37 100%);
    border: 3px solid #b8860b;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: 0 5px 14px rgba(0,0,0,0.4);
    text-transform: uppercase;
    letter-spacing: 1px;
}
#btn-nuova-partita:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

/* I richiami agli altri giochi (miniature comprese) stanno in richiami.css,
   condiviso fra dama, mulino e scacchi. */

/* === MODALI E DIALOGHI === */
.form-mulino {
    z-index: 40000;
    position: absolute;
    width: 500px;
    height: 540px;
    left: 262px;
    top: 105px;
    background-color: #1a4224;
    background-image: url(images/scala40/tappetoverde.png);
    border: 4px solid #b8860b;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
    box-sizing: border-box;
    display: none;
    flex-direction: column;
    align-items: center;
    padding: 25px;
    color: white;
    overflow: hidden;
}

.form-mulino-title {
    font-family: 'Slackey', 'Outfit', sans-serif;
    font-size: 26px;
    color: #ffd700;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px #000;
    text-align: center;
}

#modale-inizio {
    justify-content: center;
}

.btn-opzione-sel {
    background: #1f4068;
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.6);
    padding: 8px 16px;
    font-size: 14px;
    font-weight: bold;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 120px;
    text-transform: uppercase;
    opacity: 0.55;
    filter: blur(0.5px);
}
.btn-opzione-sel.attiva {
    background: linear-gradient(180deg, #ffd700 0%, #b8860b 100%);
    border: 2px solid #ffd700;
    color: #1a1a2e;
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.5);
    opacity: 1;
    filter: none;
}
.btn-opzione-sel:hover {
    opacity: 0.85;
    filter: none;
    color: #fff;
    border-color: rgba(255, 255, 255, 0.4);
}
.btn-opzione-sel.attiva:hover {
    filter: brightness(1.1);
    opacity: 1;
}

.btn-continua {
    padding: 10px 30px;
    font-size: 15px;
    font-weight: bold;
    color: #2c3e50;
    background: #ffd700;
    border: 2px solid #b8860b;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}
.btn-continua:hover {
    background: #fff;
    transform: scale(1.05);
}

/* Modale conferma nuova partita: bassa e larga, con banner pubblicitario sopra */
#confermatermina.modale-conferma {
    width: 700px;
    height: 180px;
    left: 162px;
    top: 470px;
    padding: 24px 25px;
    justify-content: center;
    overflow: visible; /* il banner sporge sopra la modale */
}
.conferma-bottoni {
    display: flex;
    justify-content: center;
    gap: 24px;
}

/* Modale fine partita: bassa e larga, con banner pubblicitario sopra */
#finepartita.modale-fine {
    width: 700px;
    height: 210px;
    left: 162px;
    top: 430px;
    padding: 20px 25px;
    justify-content: center;
    overflow: visible; /* il banner sporge sopra la modale */
}

.confirm-message {
    font-family: 'Slackey', 'Outfit', sans-serif;
    font-size: 24px;
    color: white;
    text-align: center;
    margin-bottom: 40px;
    text-shadow: 2px 2px 4px #000;
    padding: 0 20px;
}

/* === LINK A FONDO PAGINA === */
.legal-links-mulino {
    position: absolute;
    bottom: 12px;
    left: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 100;
    font-size: 11px;
}
.legal-links-mulino a {
    color: #cde8cd;
    text-decoration: none;
    transition: color 0.2s;
}
.legal-links-mulino a:hover {
    color: #ffd700;
    text-decoration: underline;
}
.legal-links-mulino .sep { color: #6b9b7a; }

.link-giochi-mulino {
    position: absolute;
    bottom: 8px;
    right: 15px;
    display: flex;
    gap: 5px;
    z-index: 100;
}
.pulsante-link-mulino {
    height: 26px;
    line-height: 26px;
    background: rgba(0,0,0,0.4);
    border: 1px solid #6b9b7a;
    color: white;
    border-radius: 4px;
    padding: 0 8px;
    cursor: pointer;
    font-size: 11px;
    font-weight: bold;
    text-decoration: none;
    transition: all 0.2s;
    box-sizing: border-box;
}
.pulsante-link-mulino:hover {
    background: rgba(0, 60, 20, 0.7);
    border-color: rgba(255, 255, 255, 0.5);
}

/* "TUTTI I GIOCHI": è l'uscita verso il resto del sito, quindi va distinto dai
   link ai singoli giochi. Classe a parte e non ritocco di .pulsante-link-mulino,
   che veste anche gli altri pulsanti della barra. La barra è flex con padding
   sul contenuto: il pulsante si allarga da sé, non serve fissare una width. */
.pulsante-home-mulino {
    background: linear-gradient(135deg, #c9720f, #8a4a08);
    border-color: #ffd700;
    color: #fff;
    white-space: nowrap;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.35);
}
.pulsante-home-mulino:hover {
    background: linear-gradient(135deg, #e08514, #a3580a);
    border-color: #ffd700;
    box-shadow: 0 0 14px rgba(255, 215, 0, 0.65);
}
