/* Dama cinese - lucianomanenti.com */
/* === ASPETTO COMUNE (doc/testa-canonica.md, 11.2) === */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #1a5f2a;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    -webkit-user-select: none;
    user-select: none;
}

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

/* Le colonne le crea site.js: queste regole servono a quelle */
.sidebar {
    position: absolute;
    top: 0;
    height: 100%;
    background: linear-gradient(135deg, #1a6b30 0%, #145524 50%, #0f4a1c 100%);
    overflow-y: auto;
    display: none;
    flex-direction: column;
    align-items: center;
    z-index: 1;
    flex-shrink: 0;
}
#sidebar-left  { left: 0; }
#sidebar-right { right: 0; }

#campogioco {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1024px;
    height: 750px;
    background: linear-gradient(135deg, #1a5f2a 0%, #0f4a1c 50%, #145524 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.3);
    overflow: hidden;
}

#schermo {
    display: none;
    position: absolute;
    top: 0; left: 0;
    width: 1024px; height: 750px;
    background: rgba(0,0,0,0.6);
    z-index: 30000;
}

/* Pulsanti del gioco sul campo, REGOLE compreso */
.pulsante2 {
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    background: linear-gradient(180deg, #4a7c59 0%, #2d5a3d 100%);
    border: 2px solid #6b9b7a;
    border-radius: 8px;
    color: #fff;
    font-weight: bold;
    text-decoration: none;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    cursor: pointer;
    user-select: none;
    transition: all 0.2s;
}
.pulsante2:hover  { background: linear-gradient(180deg, #5a8c69 0%, #3d6a4d 100%); transform: scale(1.05); }
.pulsante2:active { transform: scale(0.95); }

/* Fila dei link agli altri giochi */
.link-giochi a { text-decoration: none; }
.pulsante-link {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #888;
    border-radius: 8px;
    color: #fff;
    font-weight: bold;
    text-align: center;
    text-decoration: none;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    cursor: pointer;
    transition: transform 0.2s;
}
.pulsante-link:hover { transform: scale(1.1); }

.pulsante-home {
    background: linear-gradient(135deg, #c9720f, #8a4a08);
    border-color: #ffd700;
    letter-spacing: 0;
    white-space: nowrap;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.35);
}
.pulsante-home:hover {
    background: linear-gradient(135deg, #e08514, #a3580a);
    box-shadow: 0 0 14px rgba(255, 215, 0, 0.65);
}

#btn-scrivetemi { background-color: #3a3a5a; }

/* Selettore delle lingue sul campo */
#lang-switcher {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    gap: 4px;
    align-items: center;
    z-index: 2000;
}
.btn-lang {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    padding: 4px 10px;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    color: white;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-lang.active { background: #ffd700; color: #1a1a2e; border-color: #b8860b; }
.btn-lang:hover:not(.active) { background: rgba(255, 255, 255, 0.3); }

/* Link legali */
.legal-links-text {
    position: absolute;
    font-size: 10px;
    color: rgba(255,255,255,0.4);
    display: flex;
    gap: 15px;
    z-index: 10;
}
.legal-links-text a { color: inherit; text-decoration: none; }
.legal-links-text a:hover { color: rgba(255,255,255,0.7); }

/* Finestre */
.modal {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #1a3a2a, #0f2a1c);
    border: 1px solid #4a7a5a;
    border-radius: 10px;
    padding: 20px 30px;
    z-index: 31000;
    min-width: 340px;
    max-width: 460px;
    color: #fff;
    text-align: left;
}
.modal h2 { text-align: center; color: #ffd700; margin-bottom: 16px; font-size: 20px; letter-spacing: 1px; }
.modal-content { font-size: 14px; line-height: 1.8; color: #ccc; margin-bottom: 16px; }
.modal-content p { margin-bottom: 6px; }
.modal-content label { display: block; cursor: pointer; padding: 2px 0; }

.btn-modal {
    display: block;
    width: 100%;
    padding: 10px;
    margin-top: 6px;
    background: linear-gradient(180deg, #3a7a4a, #2a5a3a);
    border: 1px solid #6b9b7a;
    border-radius: 6px;
    color: #fff;
    font-size: 15px;
    font-weight: bold;
    text-align: center;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-modal:hover { background: linear-gradient(180deg, #4a8a5a, #3a6a4a); }

/* Il pulsante che porta avanti il gioco: oro pieno, come la lingua accesa.
   Uno per finestra, e lo porta sempre #btn-inizia */
.btn-modal.preferito { background: #ffd700; border-color: #ffd700; color: #2c3e50; }
.btn-modal.preferito:hover { background: #ffe44d; border-color: #ffe44d; }

/* Pulsante secondario di una finestra (abbandona, annulla) */
.btn-modal.secondario { background: rgba(0,0,0,0.3); border-color: #555; font-size: 13px; padding: 7px; margin-top: 4px; }
.btn-modal.secondario:hover { background: rgba(0,0,0,0.5); }

/* Vie di fuga nella finestra di inizio. Il padding in fondo è la fascia dei
   due pulsanti d'angolo: senza, finirebbero sopra INIZIA */
#modal-nuova { padding-bottom: 48px; }
.lang-switch-modale { position: absolute; top: 10px; right: 12px; display: flex; gap: 4px; z-index: 1; }
.lang-switch-modale a {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 24px;
    padding: 0 9px;
    box-sizing: border-box;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    color: white;
    font-size: 11px;
    font-weight: bold;
    transition: all 0.2s;
}
.lang-switch-modale a.active { background: #ffd700; color: #1a1a2e; border-color: #b8860b; }
.lang-switch-modale a:hover:not(.active) { background: rgba(255, 255, 255, 0.3); }

.btn-angolo-modale {
    position: absolute;
    bottom: 12px;
    height: 24px;
    line-height: 22px;
    padding: 0 10px;
    box-sizing: border-box;
    font-size: 10px;
    font-weight: bold;
    text-decoration: none;
    text-align: center;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid #6b9b7a;
    border-radius: 4px;
    color: #fff;
    transition: all 0.2s;
}
.btn-angolo-modale:hover { background: rgba(0, 60, 20, 0.7); border-color: rgba(255, 255, 255, 0.5); }
.btn-angolo-modale.sinistra { left: 14px; }
.btn-angolo-modale.destra   { right: 14px; }
.btn-angolo-modale.home {
    background: linear-gradient(135deg, #c9720f, #8a4a08);
    border-color: #ffd700;
    white-space: nowrap;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.35);
}
.btn-angolo-modale.home:hover {
    background: linear-gradient(135deg, #e08514, #a3580a);
    border-color: #ffd700;
    box-shadow: 0 0 14px rgba(255, 215, 0, 0.65);
}
/* === AUDIO TOGGLE BUTTON === */
.btn-audio-game {
    display: inline-block;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    background-color: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='white' d='M3 9v6h4l5 5V4L7 9H3z'/><path fill='white' d='M16.5 12c0-1.77-1.02-3.29-2.5-4.03v8.06c1.48-.73 2.5-2.25 2.5-4.03z'/><path fill='white' fill-opacity='0.65' d='M14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z'/></svg>");
    background-size: 18px;
    background-repeat: no-repeat;
    background-position: center;
    transition: background-color 0.2s;
    flex-shrink: 0;
}
.btn-audio-game:hover {
    background-color: rgba(255, 255, 255, 0.25);
}
.btn-audio-game.muted {
    background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='white' fill-opacity='0.45' d='M3 9v6h4l5 5V4L7 9H3z'/><path fill='white' fill-opacity='0.2' d='M16.5 12c0-1.77-1.02-3.29-2.5-4.03v8.06c1.48-.73 2.5-2.25 2.5-4.03z'/><path fill='white' fill-opacity='0.2' d='M14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z'/><line x1='3' y1='21' x2='21' y2='3' stroke='%23ee1111' stroke-width='2.5' stroke-linecap='round'/></svg>");
}


/* === TAVOLA === */
#tavola { position: absolute; left: 50px; top: 56px; width: 560px; height: 640px; }
.centro { fill: #d9b77e; }
.punta { fill: #c9a367; stroke: #8b5a2b; stroke-width: 1.5; stroke-linejoin: round; }
.punta.col-0 { fill: #d98a7c; }
.punta.col-1 { fill: #e8d27a; }
.punta.col-2 { fill: #8fbf86; }
.punta.col-3 { fill: #8aa9d6; }
.punta.col-4 { fill: #eee8dc; }
.punta.col-5 { fill: #b794c9; }
.bordo-stella { fill: none; stroke: #5d3a1a; stroke-width: 6; stroke-linejoin: round; pointer-events: none; }
.buca { fill: rgba(60, 35, 10, 0.35); stroke: rgba(60, 35, 10, 0.55); stroke-width: 1; }
.buca.cliccabile { cursor: pointer; }
.buca.arrivo { fill: rgba(60, 35, 10, 0.55); stroke: #ffe44d; stroke-width: 4; cursor: pointer; }
.buca.arrivo:hover { fill: rgba(255, 228, 77, 0.6); }
.buca.consiglio { fill: #1d7a3d; stroke: #3fe07a; stroke-width: 5; }
.traccia { fill: none; stroke: rgba(40, 20, 0, 0.55); stroke-width: 4; stroke-dasharray: 2 8; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.traccia.consiglio { stroke: #0b7a35; }
.pedina { pointer-events: none; stroke: rgba(0, 0, 0, 0.6); stroke-width: 1; }
.pedina.scelta { stroke: #ffd700; stroke-width: 4; }

/* === PANNELLO === */
#titolo { position: absolute; left: 664px; top: 14px; width: 330px; text-align: center; color: #ffd700; font-size: 25px; letter-spacing: 0.5px; white-space: nowrap; text-shadow: 2px 2px 4px rgba(0,0,0,0.6); }
#messaggio-stato { position: absolute; left: 664px; top: 62px; width: 330px; height: 52px; display: flex; align-items: center; justify-content: center; text-align: center; padding: 0 10px; background: rgba(0,0,0,0.45); border: 1px solid #6b9b7a; border-radius: 8px; color: #fff; font-size: 15px; font-weight: bold; }
#messaggio-stato.giallo { color: #ffd700; }
#messaggio-stato.rosso { color: #ff9a8a; }
#classifica { position: absolute; left: 664px; top: 124px; width: 330px; min-height: 216px; padding: 8px; background: rgba(0,0,0,0.45); border: 1px solid #6b9b7a; border-radius: 8px; color: #fff; }
.riga-giocatore { display: flex; align-items: center; gap: 8px; height: 33px; padding: 0 8px; font-size: 14px; border: 1px solid transparent; border-radius: 6px; }
.riga-giocatore.attivo { border-color: #ffd700; background: rgba(255, 215, 0, 0.12); }
.bollo { width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.6); flex-shrink: 0; }
.chi { width: 64px; font-weight: bold; }
.barra { flex: 1; height: 10px; background: rgba(255,255,255,0.15); border-radius: 5px; overflow: hidden; }
.barra b { display: block; height: 100%; }
.conto { width: 40px; text-align: right; }
.bollo.col-0, .barra .col-0 { background: #d9342b; }
.bollo.col-1, .barra .col-1 { background: #f2c81e; }
.bollo.col-2, .barra .col-2 { background: #2fa343; }
.bollo.col-3, .barra .col-3 { background: #2f6fd0; }
.bollo.col-4, .barra .col-4 { background: #f4f4f4; }
.bollo.col-5, .barra .col-5 { background: #8e44ad; }
#info { position: absolute; left: 664px; top: 350px; width: 330px; padding: 8px 16px; background: rgba(0,0,0,0.45); border: 1px solid #6b9b7a; border-radius: 8px; color: #ddd; font-size: 14px; line-height: 1.7; display: grid; grid-template-columns: 1fr 1fr; column-gap: 12px; }
#info b { color: #ffd700; }
button.pulsante2 { font-family: inherit; }
.pulsante2:disabled { opacity: 0.45; cursor: default; transform: none; }
#btn-annulla, #btn-hint, #btn-nuova, #btn-regole { position: absolute; width: 160px; height: 42px; font-size: 14px; }
#btn-annulla { left: 664px; top: 434px; }
#btn-hint { left: 834px; top: 434px; }
#btn-nuova { left: 664px; top: 486px; }
#btn-regole { left: 834px; top: 486px; }
.link-giochi { position: absolute; left: 20px; top: 706px; width: 876px; display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; }
.link-giochi .pulsante-link { height: 34px; font-size: 12px; }
.link-giochi .pulsante-link:not(.pulsante-home) { background: linear-gradient(180deg, #4a7c59 0%, #2d5a3d 100%); border-color: #6b9b7a; }
#btn-scrivetemi { position: absolute; left: 904px; top: 706px; width: 100px; height: 34px; font-size: 12px; }
.legal-links-text { left: 664px; width: 330px; top: 672px; justify-content: center; }

/* === FINESTRE === */
#modal-nuova { width: 440px; }
#modal-nuova h2 { text-align: left; }
.scelta-titolo { color: #ffd700; font-size: 13px; margin: 8px 0 4px; }
.scelte { display: flex; gap: 6px; }
.scelte button { flex: 1; height: 36px; font-family: inherit; font-size: 14px; font-weight: bold; color: #fff; background: rgba(0,0,0,0.3); border: 1px solid #6b9b7a; border-radius: 6px; cursor: pointer; }
.scelte button:hover { background: rgba(255,255,255,0.12); }
.scelte button.attiva { border-color: #ffd700; color: #ffd700; background: rgba(255,215,0,0.15); }
.btn-modal { font-family: inherit; }
#modal-fine { width: 460px; top: 430px; transform: translateX(-50%); text-align: center; }
#fine-messaggio { color: #ffd700; font-size: 22px; font-weight: bold; line-height: 1.4; }
#fine-dettagli { color: #ccc; font-size: 13px; margin: 8px 0; }
