/* ============================================================================
   RIMBALZO - Stili CSS (forma canonica, doc/testa-canonica.md sezione 11.2)
   ============================================================================ */

/* === BLOCCO COMUNE DEL SITO (testa-canonica 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); }

/* Pulsante dell'audio (rummy.css) */
.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>");
}

/* 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); }

.btn-modal.preferito { background: #ffd700; border-color: #ffd700; color: #2c3e50; }
.btn-modal.preferito:hover { background: #ffe44d; border-color: #ffe44d; }

.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 */
#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);
}

/* ============================================================================
   POSIZIONAMENTO PEZZI COMUNI E TAVOLO DI RIMBALZO
   ============================================================================ */

#btn-regole {
    position: absolute;
    top: 10px;
    left: 132px;
    height: 32px;
    padding: 0 12px;
    font-size: 12px;
    z-index: 2000;
}

#btn-scrivetemi {
    height: 34px;
    padding: 0 14px;
    font-size: 12.5px;
    white-space: nowrap;
    flex-shrink: 0;
}

#titolo-gioco {
    position: absolute;
    top: 8px;
    left: 465px;
    transform: translateX(-50%);
    color: #ffd700;
    font-size: 26px;
    font-weight: 800;
    letter-spacing: 3px;
    text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.75);
    z-index: 100;
    white-space: nowrap;
}

#messaggio-stato {
    position: absolute;
    top: 52px;
    left: 322px;
    transform: translateX(-50%);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    background: rgba(0, 35, 10, 0.65);
    padding: 6px 20px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    max-width: 560px;
    white-space: nowrap;
    z-index: 100;
    transition: background-color 0.2s, border-color 0.2s;
}
#messaggio-stato.stato-tu { border-color: rgba(110, 185, 255, 0.65); }
#messaggio-stato.stato-pc { border-color: rgba(255, 130, 130, 0.65); }
#messaggio-stato.stato-vittoria {
    background: rgba(28, 125, 60, 0.9);
    border-color: #ffd700;
    color: #fff8cc;
}
#messaggio-stato.stato-sconfitta {
    background: rgba(145, 25, 35, 0.9);
    border-color: #ff9999;
}

/* === AREA GRIGLIA 7x7 === */
#area-griglia {
    position: absolute;
    top: 90px;
    left: 322px;
    transform: translateX(-50%);
}

#cornice-griglia {
    position: relative;
    width: 544px;
    height: 544px;
    padding: 14px;
    background: #103b1b;
    border-radius: 16px;
    border: 3px solid rgba(255, 215, 0, 0.38);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5), inset 0 0 16px rgba(0, 0, 0, 0.45);
}

#nota-ai {
    width: 544px;
    margin-top: 8px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: rgba(0, 0, 0, 0.52);
    border: 1.5px solid #ffd700;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.nota-ai-testo {
    text-align: left;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.35;
    color: #fff6cc;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
}

#griglia-rimbalzo {
    position: relative;
    width: 516px;
    height: 516px;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(7, 1fr);
    gap: 6px;
    z-index: 2;
}

#svg-overlay {
    position: absolute;
    top: 14px;
    left: 14px;
    width: 516px;
    height: 516px;
    pointer-events: none;
    z-index: 6;
}

/* === CELLE === */
.cella {
    position: relative;
    border-radius: 10px;
    background: #fdf9ec;
    border: 2px solid #d4cbb0;
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.22);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 27px;
    font-weight: 800;
    color: #2c3e50;
    transition: transform 0.14s ease, background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    cursor: default;
}

.cella.val-1 { color: #1b6ca8; }
.cella.val-2 { color: #b86b00; }
.cella.val-3 { color: #8c2d52; }

.cella .num-mossa {
    position: absolute;
    top: 3px;
    right: 5px;
    font-size: 10px;
    font-weight: 700;
    opacity: 0.72;
}

.cella.occupata-start {
    background: linear-gradient(145deg, #5d6d7e, #3f4c59);
    border-color: #2c3742;
    color: rgba(255, 255, 255, 0.55);
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.35);
}

.cella.occupata-tu {
    background: linear-gradient(145deg, #2e72d2, #1d4f9a);
    border-color: #163b75;
    color: rgba(255, 255, 255, 0.65);
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.35);
}

.cella.occupata-pc {
    background: linear-gradient(145deg, #d63b4e, #9e1f2f);
    border-color: #751320;
    color: rgba(255, 255, 255, 0.65);
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.35);
}

.cella.valida {
    cursor: pointer;
    background: #fffbe0;
    border: 3px solid #f0b400;
    box-shadow: 0 0 0 2px rgba(255, 215, 0, 0.45), 0 4px 12px rgba(0, 0, 0, 0.35);
    animation: impulsoValida 1.6s ease-in-out infinite;
    z-index: 3;
}
.cella.valida:hover {
    transform: translateY(-3px) scale(1.04);
    background: #fff3b0;
    border-color: #ffda33;
    box-shadow: 0 0 16px rgba(255, 215, 0, 0.85), 0 6px 14px rgba(0, 0, 0, 0.4);
    animation: none;
}

@keyframes impulsoValida {
    0%, 100% { box-shadow: 0 0 0 2px rgba(255, 215, 0, 0.35), 0 3px 10px rgba(0, 0, 0, 0.3); }
    50% { box-shadow: 0 0 0 5px rgba(255, 215, 0, 0.72), 0 4px 14px rgba(0, 0, 0, 0.35); }
}

.cella.risposta-preview::after {
    content: '';
    position: absolute;
    bottom: 6px;
    left: 6px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #ff5252;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
    pointer-events: none;
}
.cella.risposta-preview-sol::after { background: #27ae60; }

.cella.valida.mossa-vincente:hover {
    background: #d7f8df;
    border-color: #2ecc71;
    box-shadow: 0 0 18px rgba(46, 204, 113, 0.9), 0 6px 14px rgba(0, 0, 0, 0.4);
}

.cella.corrente { z-index: 4; }

/* === PEDINA CONDIVISA ANIMATA === */
#pedina {
    position: absolute;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: radial-gradient(circle at 32% 30%, #fff6b8 0%, #ffd700 45%, #c78b00 100%);
    border: 3px solid #fff;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.55), inset 0 2px 4px rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 25px;
    font-weight: 900;
    color: #2b1d00;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.65);
    pointer-events: none;
    z-index: 10;
    transition: left 0.28s cubic-bezier(0.25, 0.9, 0.35, 1.15), top 0.28s cubic-bezier(0.25, 0.9, 0.35, 1.15), transform 0.2s ease;
}
#pedina.salto { transform: scale(1.22); }
#pedina.bloccata {
    background: radial-gradient(circle at 32% 30%, #ff9999 0%, #d92b3a 55%, #7a0e19 100%);
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

/* === PANNELLO RECORD (ALTO DESTRA) === */
#pannello-record {
    position: absolute;
    top: 12px;
    right: 24px;
    width: 356px;
    background: rgba(0, 0, 0, 0.42);
    border: 1px solid rgba(255, 215, 0, 0.32);
    border-radius: 10px;
    padding: 8px 14px 10px 14px;
    color: #fff;
}

.record-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.7px;
    color: #ffd700;
    margin-bottom: 6px;
}

.btn-reset-record {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #ccc;
    width: 24px;
    height: 22px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-reset-record:hover { border-color: #ffd700; color: #ffd700; }

.record-righe {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.record-valore {
    font-size: 19px;
    font-weight: 800;
    color: #fff;
    margin-top: 1px;
}

/* === PANNELLO CONTROLLI (DESTRA) === */
#pannello-controlli {
    position: absolute;
    top: 108px;
    right: 24px;
    width: 356px;
    height: 534px;
    background: rgba(0, 0, 0, 0.40);
    border: 1px solid #6b9b7a;
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    color: #fff;
}

#info-partita {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 7px;
}

.info-blocco {
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 6px 8px;
    text-align: center;
}
.info-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #aed6ae;
}
.info-valore {
    font-size: 18px;
    font-weight: 800;
    color: #fff;
    margin-top: 1px;
}
.info-valore.passo-evidenza { color: #ffd700; }

.sezione-controllo {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.sezione-label, .mod-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #d6ebd9;
    margin-bottom: 4px;
}

.riga-bottoni {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.btn-scelta {
    padding: 7px 4px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.1);
    color: #e8f5eb;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}
.btn-scelta:hover { background: rgba(255, 255, 255, 0.2); }
.btn-scelta.attiva {
    background: #ffd700;
    color: #1a1a2e;
    border-color: #b8860b;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.sezione-opzioni { padding: 2px; }
.toggle-opt {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: #e2f2e6;
    cursor: pointer;
}
.toggle-opt input {
    width: 15px;
    height: 15px;
    accent-color: #ffd700;
    cursor: pointer;
}

#legenda {
    background: rgba(0, 0, 0, 0.26);
    border-left: 3px solid #ffd700;
    border-radius: 0 8px 8px 0;
    padding: 8px 10px;
    font-size: 12px;
    line-height: 1.45;
    color: #e6f3e8;
    flex: 1;
}

.azioni-partita {
    display: grid;
    grid-template-columns: 1fr 1.45fr;
    gap: 8px;
    margin-top: auto;
}
.btn-azione-sec, .btn-azione-pri {
    height: 40px;
    font-size: 13px;
}
.btn-azione-sec:disabled {
    opacity: 0.38;
    cursor: not-allowed;
    transform: none;
}

/* === BARRA INFERIORE (LINK LEGALI E ALTRI GIOCHI) === */
.legal-links-text {
    bottom: 4px;
    left: 14px;
}

.link-giochi {
    position: absolute;
    bottom: 22px;
    right: 14px;
    display: flex;
    gap: 4px;
    z-index: 100;
}
.link-giochi .pulsante-link {
    height: 26px;
    padding: 0 7px;
    font-size: 10px;
    white-space: nowrap;
}
.link-c1 { background-color: #3a5a4a; }
.link-c2 { background-color: #5a4a3a; }
.link-c3 { background-color: #5a3a3a; }
.link-c4 { background-color: #3a4a5a; }
.link-c5 { background-color: #4a3a5a; }
.link-c6 { background-color: #2f5555; }
.link-c7 { background-color: #5a3a4d; }

/* === DETTAGLI MODALI === */
.mod-gruppo { margin-bottom: 14px; }
.mod-nota {
    font-size: 12.5px;
    line-height: 1.45;
    color: #b7d7bf;
    background: rgba(0, 0, 0, 0.25);
    border-left: 3px solid #ffd700;
    padding: 8px 10px;
    border-radius: 0 6px 6px 0;
}

/* Finestra fine partita nella metà bassa del campo: lascia spazio in alto per il
   riquadro di fine partita (setupAmazonFinishBanner, 250px + 15px stacco) */
#modal-fine {
    top: 410px;
    left: 512px;
    transform: translateX(-50%);
    width: 460px;
    max-width: 460px;
    overflow: visible;
    text-align: center;
}
#modal-fine.esito-vittoria  { border: 2px solid #ffd700; }
#modal-fine.esito-sconfitta { border: 2px solid #c94a5a; }

.fine-sotto {
    font-size: 15px;
    color: #fff;
    margin-bottom: 10px;
    line-height: 1.4;
}
.fine-stats {
    background: rgba(0, 0, 0, 0.28);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13.5px;
    color: #d6ebd9;
    line-height: 1.55;
}
