/* --- SHIMMER GRADIENT ANIMATO PER ACCEDI --- */
.shimmer-text {
    font-size: 1.15em;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #6da5ff;
    background: linear-gradient(
        to right,
        #6da5ff 48.5%,
        #ffffff 50%,
        #6da5ff 51.5%
    );
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shine 2s linear infinite;
}

@keyframes shine {
    0% {
        background-position: 100% center;
    }
    100% {
        background-position: -100% center;
    }
}
/* --- VARIABILI E RESET --- */
:root { 
    --bg: #2c2e31; 
    --card: #161616; 
    --text: #eee; 
    --gold: #ffd700; 
    --p1: #ff4757; 
    --p2: #54a0ff; 
    --accent: rgba(255, 30, 50, 0.9);
    --shop-banner-height: 28px;
    --stats-bar-height: 24px;
    --stats-edge-gap: 12px;
    --lang-selector-bottom: calc(var(--shop-banner-height) + var(--stats-bar-height) + 10px);
    --lang-trigger-height: 28px;
    --lang-badge-gap: 10px;
    /*--footer-reserve: clamp(180px, 28vh, 320px);*/
    --footer-reserve: clamp(120px, 22vh, 180px);
}

/* --- DISABLE SCROLLING FOR GAME PAGE --- */
html.game-page, body.game-page {
    height: 100vh;
    min-height: 100vh;
    max-height: 100vh;
    width: 100%;
    overflow: hidden; /* Prevent scrolling */
    margin: 0;
    padding: 0;
}

@supports (height: 100dvh) {
    html.game-page, body.game-page {
        height: 100dvh;
        min-height: 100dvh;
        max-height: 100dvh;
    }
}

body.game-page {
    display: flex;
    flex-direction: column;
}

html.game-page {
    background: var(--bg);
}

/* (removed site-wide zoom; restored native browser scaling) */

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
}
/* Hide any scrollbar for game page */
html.game-page, body.game-page {
    scrollbar-width: none; /* Firefox */
}
html.game-page::-webkit-scrollbar, body.game-page::-webkit-scrollbar {
    width: 0;
    height: 0;
}

#pool {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
        gap: 0;
    flex-wrap: wrap;
    min-height: 50px;
    min-width: 0;
    width: 100%;
    margin: 0 auto;
    max-height: 100%;
    overflow: hidden;
}
.game-page {
    font-size: clamp(0.855rem, 0.76rem + 0.38vw, 0.95rem);
}
.game-page .header,
.game-page #gameLayout,
.game-page .footer,
.game-page .lang-selector-fixed,
.game-page .shop-banner {
    zoom: 1;
}

/* --- LOGO TERXO INTEGRATO NELLA NAV --- */
.nav-logo-link {
    width: clamp(68px, 8.4vw, 92px);
    min-width: clamp(68px, 8.4vw, 92px);
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    flex: 0 0 auto;
    overflow: hidden;
}

.nav-logo {
    height: 55%;
    width: auto;
    max-width: 100%;
    max-height: 55%;
    object-fit: contain;
    opacity: 0.88;
    transition: opacity 0.25s ease, transform 0.2s ease, filter 0.2s ease;
}

.nav-logo-link:hover .nav-logo {
    opacity: 1;
    transform: scale(1.04);
    filter: drop-shadow(0 0 10px var(--accent));
}

.under-construction-badge {
    position: fixed;
    right: 16px;
    bottom: calc(var(--lang-selector-bottom) + var(--lang-trigger-height) + var(--lang-badge-gap));
    transform: none;
    width: clamp(4rem, 8vw, 5.5rem);
    height: clamp(4rem, 8vw, 5.5rem);
    opacity: 0.5;
    pointer-events: none;
    user-select: none;
    z-index: 10040;
}

.btn-refresh {
    background: #e53935; /* red */
    color: #fff;
    border: 0;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
        margin: 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.35);
}

.btn-refresh:hover { background: #d32f2f; }

/* --- HEADER E SCOREBOARD --- */
.header { 
    padding: clamp(0.6rem, 1.4vw, 1rem); 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    gap: clamp(0.5rem, 1.2vw, 0.9rem); 
    position: relative;
    z-index: 10050; 
    flex-shrink: 0; 
    background: #1f2023;
}

.nav-row { 
    display: flex; 
    gap: clamp(0.28rem, 0.65vw, 0.48rem); 
    align-items: center;
    justify-content: flex-start;
    flex-wrap: nowrap;
    width: 100%;
    min-width: 0;
}

.nav-row .nav-logo-link {
    margin-right: auto;
}

.nav-row .match-options {
    margin-left: auto;
}

#bUndo,
#bRedo {
    display: none !important;
}

@media (max-width: 760px) {
    .nav-row {
        gap: clamp(0.22rem, 1.05vw, 0.42rem);
    }
}

@media (max-width: 600px) {
    .header {
        padding: clamp(0.5rem, 3vw, 0.9rem);
    }
    .nav-row {
        gap: clamp(0.18rem, 1.4vw, 0.35rem);
    }
    .header .btn {
        padding: clamp(5px, 1.5vw, 7px) clamp(7px, 2vw, 10px);
        font-size: clamp(0.63rem, 2.2vw, 0.78rem);
    }
    #headerRefreshStateBtn,
    .btn-options,
    .nav-logo-link {
        width: 36px;
        height: 36px;
    }
    .nav-logo-link {
        width: clamp(56px, 16vw, 68px);
        min-width: clamp(56px, 16vw, 68px);
    }
    #headerNewOnlineBtn,
    .header .btn-rules {
        min-height: 36px;
        min-width: clamp(78px, 18vw, 112px);
        padding: 4px clamp(6px, 1.6vw, 9px);
        font-size: clamp(0.5rem, 1.8vw, 0.66rem);
    }
    #headerNewOnlineBtn {
        letter-spacing: 0.3px;
    }
}

@media (max-width: 430px) {
    #headerNewOnlineBtn,
    .header .btn-rules {
        min-width: clamp(64px, 19vw, 88px);
        padding: 3px 6px;
        font-size: clamp(0.46rem, 2.35vw, 0.58rem);
    }
    #headerNewOnlineBtn {
        letter-spacing: 0;
    }
}

/* --- LANGUAGE SELECTOR --- */
.lang-selector-fixed {
    position: fixed;
    right: 16px;
    bottom: var(--lang-selector-bottom);
    top: auto;
    z-index: 10060;
    display: inline-flex;
    flex-direction: column-reverse;
    align-items: flex-end;
    gap: 4px;
}
.lang-trigger {
    display: inline-flex;
    align-items: center;
    border: 1px solid #2b2b2b;
    background: #1a1a1a;
    cursor: pointer;
}
.lang-label {
    padding: 4px 7px;
    font-size: 8.4px; /* -30% */
    letter-spacing: 0.42px; /* -30% */
    text-transform: uppercase;
    color: #cfcfcf;
    border-right: 1px solid #2b2b2b;
}
.lang-code {
    min-width: 27px;
    text-align: center;
    padding: 4px 7px;
    font-size: 8.4px; /* -30% */
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.lang-trigger:hover { filter: brightness(1.1); }

.lang-menu {
    position: absolute;
    bottom: 110%;
    right: 0;
    display: none;
    min-width: 140px;
    background: #111;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 5px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}
.lang-menu.show { display: flex; flex-direction: column; gap: 4px; }

.lang-option {
    display: flex;
    align-items: center;
    gap: 7px;
    background: transparent;
    border: 0;
    color: #eaeaea;
    padding: 6px 8px;
    cursor: pointer;
    text-align: left;
}
.lang-option:hover { background: #2a2a2a; }

.flag-circle {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.25);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #fff;
    flex: 0 0 18px;
}
.lang-name { font-size: 9.8px; }

/* Flag circles */
.flag-circle[data-lang="it"] {
    background: linear-gradient(90deg, #009246 0 33%, #ffffff 33% 66%, #ce2b37 66% 100%);
}
.flag-circle[data-lang="fr"] {
    background: linear-gradient(90deg, #0055a4 0 33%, #ffffff 33% 66%, #ef4135 66% 100%);
}
.flag-circle[data-lang="es"] {
    background: linear-gradient(180deg, #aa151b 0 25%, #f1bf00 25% 75%, #aa151b 75% 100%);
}
.flag-circle[data-lang="pt"] {
    background: linear-gradient(90deg, #006600 0 40%, #ff0000 40% 100%);
}
.flag-circle[data-lang="de"] {
    background: linear-gradient(180deg, #000000 0 33%, #dd0000 33% 66%, #ffce00 66% 100%);
}
.flag-circle[data-lang="en"] {
    background-color: #012169;
    background-image:
        linear-gradient(90deg, transparent 0 42%, #ffffff 42% 58%, transparent 58% 100%),
        linear-gradient(0deg, transparent 0 42%, #ffffff 42% 58%, transparent 58% 100%),
        linear-gradient(90deg, transparent 0 46%, #c8102e 46% 54%, transparent 54% 100%),
        linear-gradient(0deg, transparent 0 46%, #c8102e 46% 54%, transparent 54% 100%);
}
.flag-circle[data-lang="eo"] {
    background: #0b8f3e;
    position: relative;
}
.flag-circle[data-lang="eo"]::after {
    content: "★";
    color: #ffffff;
    font-size: 10px;
    transform: translateY(-1px);
}

/* --- OPPONENT DISCONNECT OVERLAY --- */
.opponent-disconnect-overlay,
.opponent-resign-overlay,
.resign-confirm-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
}

.opponent-disconnect-overlay {
    background: rgba(0, 0, 0, 0.65);
    z-index: 10006;
}

/* --- OPPONENT RESIGN OVERLAY --- */
.opponent-resign-overlay {
    background: rgba(0, 0, 0, 0.65);
    z-index: 10007;
}

/* --- RESIGN CONFIRM OVERLAY --- */
.resign-confirm-overlay {
    background: rgba(0, 0, 0, 0.7);
    z-index: 10008;
}

.opponent-disconnect-overlay.show,
.opponent-resign-overlay.show,
.resign-confirm-overlay.show { display: flex; }

.opponent-disconnect-box,
.opponent-resign-box,
.resign-confirm-box {
    background: #101010;
    border: 1px solid #333;
    padding: 22px 28px;
    text-align: center;
}

.opponent-disconnect-box {
    min-width: 280px;
    max-width: 520px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}

.opponent-resign-box {
    width: fit-content;
    max-width: 92vw;
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}

.resign-confirm-box {
    min-width: 280px;
    max-width: 520px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.6);
}

.opponent-disconnect-text,
.opponent-resign-text,
.resign-confirm-text {
    color: #ff4d4d;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.opponent-resign-text,
.resign-confirm-text {
    margin-bottom: 16px;
}
.resign-confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}
.mode-btn.danger { background: #ff4d4d; }

.mode-btn.danger:hover:not(:disabled) { background: #ff6b6b; }

/* --- POST GAME ACTIONS --- */
.post-game-actions {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 12;
}
.post-game-actions .mode-btn {
    padding: 8px 14px;
    font-size: 11px;
}

.scoreboard { 
    background: transparent; 
    padding: clamp(6px, 1.6vw, 8px) clamp(12px, 3vw, 26px); 
    border-radius: 50px; 
    border: 0; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    flex: 0 0 auto;
    overflow: visible;
    position: relative;
    z-index: 1010;
    gap: 0;
    margin: clamp(0, 0.3vw, 2px) auto 0; 
}

.scoreboard > * {
    min-width: 0;
}

.player-ui { 
    text-align: center; 
    min-width: clamp(96px, 20vw, 150px); 
    padding: clamp(3px, 0.8vw, 5px); 
    border: 2px solid transparent; 
    border-radius: 20px; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
}

#ui-p2 {
    align-items: flex-start;
    text-align: left;
    margin-left: 0;
}

.center-point-board {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-width: 154px;
    padding: 9px 10px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.16);
    background: rgba(0, 0, 0, 0.34);
    box-shadow: inset 0 0 12px rgba(255,255,255,0.05);
}

.user-container {
    margin-right: 0;
}

#ui-p2 .p2-top {
    gap: clamp(4px, 1.2vw, 12px) !important;
    max-width: 100%;
}

.center-score-col {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
}

.center-score {
    font-family: 'Orbitron', monospace;
    font-size: clamp(1.155rem, 2.42vw, 1.595rem);
    font-weight: 700;
    letter-spacing: 1.2px;
    min-width: 2.6ch;
    text-align: center;
    line-height: 1;
}

.center-score.left { color: var(--p1); }
.center-score.right { color: var(--p2); }

.center-score-sep {
    font-family: 'Orbitron', monospace;
    font-size: clamp(1.1rem, 2.2vw, 1.485rem);
    color: rgba(255,255,255,0.72);
    line-height: 1;
}

.center-timer {
    display: none;
    font-family: 'Orbitron', monospace;
    font-size: clamp(0.58rem, 1.21vw, 0.8rem);
    letter-spacing: 0.4px;
    line-height: 1;
    color: rgba(255,255,255,0.78);
}

body[data-online="1"] .center-timer {
    display: inline-block;
}

#s1,
#s2 {
    display: none !important;
}

.player-ui.active { 
    background: rgba(255,255,255,0.05); 
}

/* Active player: no border contour; use green glow under name instead */
#ui-p1.active, #ui-p2.active { border-color: transparent; }

.p1-name { color: var(--p1); font-size: clamp(0.8rem, 2vw, 1.04rem); font-weight: bold; position: relative; display: inline-block; padding: 2px 8px; border-radius: 999px; isolation: isolate; z-index: 0; }
.p2-name { color: var(--p2); font-size: clamp(0.8rem, 2vw, 1.04rem); font-weight: bold; position: relative; display: inline-block; padding: 2px 8px; border-radius: 999px; isolation: isolate; z-index: 0; }

/* Active player glow: ONLINE ONLY (stanza). Soft green backlight behind the name (neon-like). */
body[data-online="1"] .player-ui.active .p1-name::before,
body[data-online="1"] .player-ui.active .p2-name::before {
    content: "";
    position: absolute;
    left: 6px;
    right: 6px;
    top: 55%;
    height: 70%;
    transform: translateY(-50%);
    background: rgba(76, 175, 80, 0.25);
    border-radius: 999px;
    box-shadow:
        0 0 10px rgba(76, 175, 80, 0.55),
        0 0 20px rgba(76, 175, 80, 0.35),
        0 0 34px rgba(76, 175, 80, 0.18);
    filter: blur(0.8px);
    pointer-events: none;
    z-index: -1;
}

.time-chip {
    display: inline-block;
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    color: currentColor;
    letter-spacing: 0.4px;
}

#p1Timer { margin-right: 6px; }
#p2Timer { margin-left: 6px; }

/* --- MATCH WAITING --- */
.match-waiting {
    display: none;
    margin-top: 12px;
    color: #bbb;
    font-size: 17.6px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 4px;
    align-items: center;
    gap: 10px;
}
.match-waiting.show { display: inline-flex; }
.waiting-dots { display: inline-flex; gap: 6px; }
.waiting-dots .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3a3a3a;
    opacity: 0.5;
    animation: waitingPulse 0.9s infinite;
}
.waiting-dots .dot:nth-child(1) { animation-delay: 0s; }
.waiting-dots .dot:nth-child(2) { animation-delay: 0.3s; }
.waiting-dots .dot:nth-child(3) { animation-delay: 0.6s; }

@keyframes waitingPulse {
    0% { background: #666; opacity: 0.5; }
    33% { background: #bdbdbd; opacity: 1; }
    66% { background: #4a4a4a; opacity: 0.6; }
    100% { background: #666; opacity: 0.5; }
}

/* --- MENU UTENTE E AVATAR --- */
.user-container { 
    position: relative; 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    cursor: pointer; 
}

.user-name { 
    color: var(--p2); 
    font-weight: bold; 
    font-family: inherit; 
    text-transform: uppercase; 
    font-size: 12px;
    position: relative;
    display: inline-flex;
    flex-direction: row;
    align-items: flex-end;
    text-align: right;
    line-height: 1.02;
    padding: 2px 8px;
    border-radius: 999px;
    isolation: isolate;
    z-index: 0;
    white-space: nowrap;
    gap: 4px;
}

.user-main,
.user-elo {
    display: inline-block;
}

.spectator-name {
    cursor: default;
    align-items: flex-start;
    text-align: left;
}

.user-elo {
    font-size: 0.95em;
}

.p2-name {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    line-height: 1.02;
    color: var(--p2);
    font-weight: bold;
    font-size: 14px;
    text-transform: uppercase;
    position: relative;
    padding: 2px 8px;
    border-radius: 999px;
}

#p2Label {
    white-space: pre-line;
    text-align: left;
    font-size: inherit;
    font-weight: inherit;
    text-transform: inherit;
}

body[data-online="1"] .user-name.active-turn::before,
body[data-online="1"] #ui-p2 .p2-name.active-turn::before {
    content: "";
    position: absolute;
    left: 6px;
    right: 6px;
    top: 55%;
    height: 70%;
    transform: translateY(-50%);
    background: rgba(76, 175, 80, 0.25);
    border-radius: 999px;
    box-shadow:
        0 0 10px rgba(76, 175, 80, 0.55),
        0 0 20px rgba(76, 175, 80, 0.35),
        0 0 34px rgba(76, 175, 80, 0.18);
    filter: blur(0.8px);
    pointer-events: none;
    z-index: -1;
}

.user-avatar-wrapper { 
    width: 36px; 
    height: 36px; 
    border-radius: 50%; 
    background-color: #1a1a1a; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    border: 2px solid var(--p2); 
    overflow: hidden; 
}

.meeple-svg { 
    width: 100%; 
    height: 100%; 
    display: block;
    object-fit: contain;
    pointer-events: none; 
}

.dropdown-menu { 
    display: none; 
    position: absolute; 
    top: 100%; 
    right: 0; 
    background: #1a1a1a; 
    border: 1px solid #444; 
    border-radius: 5px; 
    min-width: 150px; 
    z-index: 1000; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.5); 
    margin-top: 10px;
}

.dropdown-menu a { 
    display: block; 
    color: white; 
    padding: 10px 15px; 
    text-decoration: none; 
    font-size: 12px; 
    transition: background 0.2s; 
}

.dropdown-menu a:hover { background: #333; color: var(--p2); }
.dropdown-menu hr { border: 0; border-top: 1px solid #444; margin: 0; }
.dropdown-menu.show { display: block; }

/* --- PULSANTI --- */
.btn { 
    background: #333; 
    color: #fff; 
    border: 1px solid #555; 
    padding: 10px 22px; 
    border-radius: 6px; 
    cursor: pointer; 
    font-weight: bold; 
    transition: all 0.2s ease;
    font-size: 0.96rem; 
}

.header .btn {
    padding: clamp(6px, 1.2vw, 10px) clamp(10px, 2.4vw, 22px);
    font-size: clamp(0.7rem, 1.6vw, 0.96rem);
}

.btn:hover { background: #444; }
.btn-reset { background: rgb(132, 69, 69); border-color: #833; }
.btn-reset:hover { background: #733; }
.header .btn-reset { display: none; }
.btn-3d { background: #302bb3; border-color: #4a4aed; }
.btn-login-laser {
    position: relative;
    isolation: isolate;
    color: var(--p2);
    border: 1px solid rgba(98, 228, 255, 0.42);
    background: rgba(10, 16, 24, 0.42);
    box-shadow: 0 0 0 1px rgba(80, 208, 255, 0.14) inset;
    overflow: visible;
}

.btn-login-laser::before {
    content: "";
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    border: 1.5px solid rgba(118, 242, 255, 0.8);
    box-shadow:
        0 0 6px rgba(95, 225, 255, 0.65),
        0 0 12px rgba(80, 208, 255, 0.45),
        0 0 18px rgba(70, 196, 255, 0.3);
    opacity: 0.15;
    animation: loginLaserBorderFlash 8.2s steps(2, end) infinite;
    pointer-events: none;
    z-index: -1;
}

.btn-login-laser:hover::before {
    animation-duration: 6.6s;
}

@keyframes loginLaserBorderFlash {
    0%, 80%, 100% { opacity: 0.1; }
    85% { opacity: 0.96; }
    90% { opacity: 0.72; }
    95% { opacity: 0.28; }
}

.btn-login-laser .login-label {
    position: relative;
    display: inline-block;
    color: transparent;
    background: linear-gradient(
        100deg,
        rgba(118, 232, 255, 0.86) 0%,
        rgba(108, 226, 255, 0.9) 46%,
        rgba(250, 255, 255, 1) 49.2%,
        rgba(255, 255, 255, 1) 50%,
        rgba(250, 255, 255, 1) 50.8%,
        rgba(100, 222, 255, 0.9) 54%,
        rgba(118, 232, 255, 0.86) 100%
    );
    background-size: 260% 100%;
    background-position: 0% 50%;
    -webkit-background-clip: text;
    background-clip: text;
    animation: loginTextIntrinsicGlow 5s linear infinite;
    text-shadow: 0 0 12px rgba(110, 236, 255, 0.5);
}

@keyframes loginTextIntrinsicGlow {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

.btn-rules { background: #19ba41; border-color: #1d7e34; text-decoration: none; display: inline-flex; align-items: center; }
.header .btn-rules { min-height: 42px; min-width: clamp(106px, 12.5vw, 166px); box-sizing: border-box; justify-content: center; white-space: nowrap; line-height: 1; font-size: clamp(0.64rem, 1.2vw, 0.88rem); }
.btn-rules:hover {    background: #148a32; border-color: #16692a; }
.btn:disabled { opacity: 0.2; cursor: not-allowed; }

/* --- MATCH OPTIONS MENU (ONLINE) --- */
.match-options { position: relative; display: inline-flex; align-items: center; }
.btn-options {
    width: 42px;
    min-width: 42px;
    height: 42px;
    flex: 0 0 42px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    box-shadow: none;
}
.btn-options:hover { background: transparent; border-color: transparent; }
.btn-options .bars-icon {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
}
.btn-options .bars-icon span {
    display: block;
    width: 22px;
    height: 4px;
    border-radius: 999px;
    background: #fff;
}
.match-options-menu {
    position: absolute;
    top: 110%;
    right: 0;
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: 6px;
    min-width: 160px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.4);
    display: none;
    z-index: 1002;
    padding: 6px 0;
}
.match-options-menu.show { display: block; }
.match-options-menu .menu-item {
    width: 100%;
    background: transparent;
    border: 0;
    color: #eee;
    text-align: left;
    padding: 8px 12px;
    font-size: 12px;
    cursor: pointer;
}
.match-options-menu .menu-item:hover { background: #2a2a2a; color: #fff; }

/* --- AREA DI GIOCO (2D & 3D) --- */
.carousel-footer, .carousel-dots {
    min-height: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* Uniforma altezza example-track e example-carousel */
.example-track {
    min-height: 48px;
    height: 48px;
    display: flex;
    align-items: center;
}
#gameLayout {
    flex: 1 1 auto;
    display: flex;
    align-items: stretch;
    min-height: 0;
    position: relative;
    z-index: 1001;
    padding-bottom: 0;
    margin-bottom: 0;
    overflow: hidden;
    background: #1c1d20;
}
.chat-column {
    width: calc(34px * 1.1);
    background: #1b1c1f; /* antracite scuro */
    border-right: 1px solid #2b2b2b;
    display: flex;
    flex-direction: column;
    transition: width 0.25s ease, box-shadow 0.25s ease;
    overflow: hidden;
    position: relative;
    z-index: 10;
    height: 100%;
    max-height: 100%;
    min-height: 0;
    align-self: stretch;
    box-shadow: inset -1px 0 0 #111, 0 0 12px rgba(0,0,0,0.35);
}
#gameLayout.chat-open .chat-column { width: 300px; }
.chat-toggle {
    background: #1e1f22;
    border: 0;
    border-bottom: 1px solid #2b2b2b;
    color: #fff;
    padding: 10px 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    position: relative;
    z-index: 2;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.chat-unread-arrow {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #ff3b3b;
    text-shadow: none;
    opacity: 0;
    display: block;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    pointer-events: none;
    z-index: 9999;
}

.chat-toggle.has-unread .chat-unread-arrow {
    opacity: 1;
    animation: chatBlink 2s ease-in-out infinite;
}

.chat-toggle.has-unread .chat-arrow {
    opacity: 0;
}

.chat-arrow { font-size: 14px; color: #e6e6e6; }
.chat-bell {
    color: #ff3b3b;
    font-size: 14px;
    display: none;
}
.chat-bell.show { display: inline-block; }

@keyframes chatBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.2; }
}
.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #1e1f22; /* antracite scuro */
    height: 100%;
    min-height: 0;
    transition: opacity 0.25s ease;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

@media (max-width: 600px) {
    .chat-column {
        width: calc(33px * 1.2);
    }
}
#gameLayout.chat-open .chat-panel {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
}
.chat-header {
    padding: 8px 10px;
    font-size: 12px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #bbb;
    border-bottom: 1px solid #2b2b2b;
}
.chat-messages {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column-reverse;
    gap: 6px;
    font-size: 12px;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: #3b4244 #301717;
}
.chat-messages::-webkit-scrollbar {
    width: 10px;
    background: #301717;
}
.chat-messages::-webkit-scrollbar-track {
    background: #301717;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: #3b4244;
    border-radius: 0;
    border: 0;
}
.chat-messages::-webkit-scrollbar-button {
    display: none;
    width: 0;
    height: 0;
}
.chat-message {
    color: #eee;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
}
.chat-message .nick { color: var(--p2); font-weight: 600; margin-right: 6px; }
.chat-message .nick.nick-profile { cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.chat-message .nick.nick-profile:hover { color: #8bc4ff; }
.chat-message .nick.nick-self-logged {
    color: #b24cff;
    font-weight: 800;
    text-shadow:
        0 0 1px rgba(188, 90, 255, 0.75),
        0 0 4px rgba(164, 58, 255, 0.42);
}
.chat-message .time { color: #888; margin-right: 4px; font-size: 11px; }
.chat-message.self { font-weight: 400; }
.chat-message.self .nick { font-weight: 700; text-decoration: underline; }
.chat-message.opponent .nick { color: var(--p2); }
.chat-message.system { color: #b2bac8; font-style: italic; }
.chat-message.system .nick { color: #9aa4b6; font-weight: 600; }
.chat-message.system .time { color: #7f8898; }
.chat-input-row {
    display: flex;
    gap: 0;
    padding: 8px;
    border-top: 1px solid #2b2b2b;
    background: #1e1f22;
    align-items: center;
    position: relative;
    z-index: 5;
}
.chat-input {
    flex: 1;
    min-width: 0;
    background: #1b1c1f;
    color: #fff;
    border: 1px solid #2b2b2b;
    border-right: 0;
    border-radius: 0;
    padding: 6px 8px;
    font-size: 16px; /* prevent mobile auto-zoom on focus */
}
.chat-status {
    margin-top: 6px;
    min-height: 14px;
    font-size: 11px;
    color: #bdbdbd;
    opacity: 0.8;
}
.chat-send {
    background: #1b1c1f;
    color: #fff;
    border: 1px solid #333;
    border-left: 1px solid #2b2b2b;
    border-radius: 0;
    width: 40px;
    min-width: 40px;
    height: 34px;
    flex: 0 0 40px;
    padding: 0;
    cursor: pointer;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 6;
}
.chat-send:hover { background: #3b4244; }

#game-area { 
    flex: 1 1 auto;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #1e1f22; /* antracite */
    width: 100%;
    margin: 0;
    height: 100%;
    padding-top: clamp(3px, 0.9vh, 10px);
    padding-bottom: 0;
}

@media (max-width: 900px) {
    .scoreboard {
        padding: 4px 8px;
    }
    .player-ui {
        min-width: 74px;
        padding: 2px;
    }
    .center-point-board {
        min-width: 122px;
        padding: 7px 7px;
        gap: 6px;
    }
    .center-score {
        font-size: clamp(0.96rem, 3vw, 1.32rem);
    }
    .p1-name, .p2-name, .user-name {
        font-size: 12px;
        padding: 1px 5px;
    }
}

@media (max-width: 600px) {
    .scoreboard {
        padding: 2px 4px;
    }
    .player-ui {
        min-width: 64px;
        padding: 1px;
    }
    .center-point-board {
        min-width: 106px;
        padding: 5px 5px;
        gap: 4px;
    }
    .center-score {
        font-size: clamp(0.88rem, 3.2vw, 1.1rem);
    }
    .center-score-sep {
        font-size: clamp(0.86rem, 3vw, 1.04rem);
    }
    .center-timer {
        font-size: clamp(0.5rem, 2.3vw, 0.66rem);
    }
    .p1-name, .p2-name, .user-name {
        font-size: 11px;
        padding: 1px 4px;
    }
}

#container3d { width: 100%; height: 100%; display: block; position: relative; }

.main-game { 
    display: none;
    flex: 1 1 auto;
    justify-content: stretch;
    align-items: stretch;
    padding: 0;
    margin: 0;
    gap: 0;
    overflow-y: auto;
    background: #1e1f22; /* antracite */
}

.main-game.active { display: flex; }

.grid { 
    display: grid; 
    grid-template-columns: repeat(3, 66px);
    gap: 8px; 
    background: #8e24aa; /* viola fisso */
    padding: 12px; 
    border-radius: 15px; 
    border: 1px solid #222; 
    width: min(60vh, 100%); 
    max-width: min(60vh, 100%);
    max-height: 60vh;
    aspect-ratio: 1 / 1;
    place-content: center;
}

.cell { 
    width: 66px; 
    height: 66px; 
    background: #222; 
    border-radius: 8px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-weight: bold; 
    cursor: pointer; 
    border: 2px solid transparent; 
    font-size: 1.65rem; 
}

.cell.available { 
    background: #2a2a2a; 
    border-color: #555; 
    border-width: 2px;
    box-shadow: inset 0 0 8px rgba(100, 150, 200, 0.3);
    cursor: crosshair;
}

.cell.available:hover {
    border-color: #54a0ff;
    box-shadow: inset 0 0 12px rgba(84, 160, 255, 0.5), 0 0 10px rgba(84, 160, 255, 0.3);
}

.cell.highlight { border-color: var(--gold); box-shadow: 0 0 15px var(--gold); }

.cell.last-opponent-move {
    position: relative;
}

.cell.last-opponent-move::after {
    content: "";
    position: absolute;
    inset: 1px;
    border: 2px solid #9cff00;
    border-radius: 0;
    box-shadow: 0 0 6px rgba(156, 255, 0, 0.42);
    pointer-events: none;
}

/* --- AI MOVE FLY-IN --- */
.ai-fly-piece {
    position: fixed;
    width: 66px;
    height: 66px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22.88px;
    font-weight: bold;
    border: 2px solid rgba(0,0,0,0.2);
    pointer-events: none;
    z-index: 10004;
    transform: translate(-50%, -50%);
    box-shadow: 0 8px 18px rgba(0,0,0,0.35);
}

/* --- OVERLAYS --- */
/* Overlay */
#auth-overlay, #users-overlay, #rules-overlay, #profile-overlay, #contact-overlay, #live-matches-overlay,
#matchmakingModal, #gameModeModal, #guest-offer-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: var(--overlay-tint, hsla(210, 100%, 50%, 0.5)); /* blu saturo 50% */
    display: none; 
    justify-content: center;
    align-items: center;
    z-index: 300000; /* sopra tutto */
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
    pointer-events: auto;
}

/* Fallback for JS-less: default to black tint */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10005;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

.modal-overlay.show { display: flex; }
/* ID-specific rules to override earlier ID selectors (fix stacking/specificity issues) */
#auth-overlay.show,
#users-overlay.show,
#rules-overlay.show,
#profile-overlay.show,
#match-preferences-overlay.show,
#contact-overlay.show,
#live-matches-overlay.show,
#matchmakingModal.show,
#gameModeModal.show {
    display: flex;
}
.modal-content { 
    background: #1a1a1a; 
    border: 2px solid #54a0ff; 
    border-radius: 12px; 
    padding: 30px; 
    max-width: 600px; 
    width: 90%;
}
.modal-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 25px; 
}
.modal-header h2 { 
    color: #54a0ff; 
    text-transform: uppercase; 
    letter-spacing: 2px; 
    margin: 0; 
}
.modal-close { 
    background: none; 
    border: 0; 
    color: #888; 
    font-size: 22.4px; 
    cursor: pointer; 
    padding: 0;
    width: 30px;
    height: 30px;
}
.modal-close:hover { color: #fff; }

/* Matchmaking: smaller modal and no title */
#matchmakingModal .modal-header { margin-bottom: 8px; justify-content: flex-end; }
#matchmakingModal .modal-header h2 { display: none; }
#matchmakingModal .modal-content { max-width: 420px; padding: 18px 20px; }

/* End game modal: smaller overlay style */
#endGameModal,
#eloSummaryModal {
    z-index: 10005;
    background: rgba(8, 10, 14, 0.42);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}
#endGameModal .modal-content { width: fit-content; max-width: 92vw; padding: 18px 20px; border-width: 1px; }
#endGameModal .endgame-score-line {
    font-family: 'Orbitron', monospace;
    color: rgba(255,255,255,0.85);
    font-size: 13px;
    letter-spacing: 0.6px;
    margin-bottom: 8px;
}
#endGameModal .single-ok-btn {
    min-width: 120px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 700;
}
#endGameModal h2 { font-size: 18px; letter-spacing: 1px; color: var(--p1); }
#eloSummaryModal h2 { color: var(--p1); }

.game-modes-grid { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 20px; 
}
.game-mode-card { 
    background: #222; 
    border: 2px solid #333; 
    border-radius: 10px; 
    padding: 25px; 
    text-align: center; 
    transition: 0.2s;
}
.game-mode-card:hover { 
    border-color: #54a0ff; 
}
.game-mode-card.disabled { 
    opacity: 0.5; 
    pointer-events: none;
}
.mode-icon { 
    font-size: 2.5rem; 
    margin-bottom: 12px; 
}
.mode-title { 
    font-size: 1.1rem; 
    text-transform: uppercase; 
    color: #fff; 
    margin-bottom: 10px; 
    letter-spacing: 1px;
}
.mode-desc { 
    font-size: 12px; 
    color: #888; 
    margin-bottom: 12px; 
    line-height: 1.4;
}
.online-status { 
    font-size: 11px; 
    color: #54a0ff; 
    font-weight: bold; 
    margin-bottom: 12px;
}
.mode-btn {
    background: #54a0ff;
    color: white;
    border: 0;
    padding: 2.5% 5%;
    border-radius: 3px;
    cursor: pointer;
    text-transform: uppercase;
    font-weight: bold;
    font-size: 0.6em;
    width: 50%;
    min-width: 40px;
    max-width: 80px;
    transition: 0.2s;
}

#playOnlineBtn {
    background: linear-gradient(135deg, #ffcc33 0%, #ff9f1a 100%);
    color: #2a1b00;
    box-shadow: 0 10px 22px rgba(255, 165, 0, 0.35);
    border: 1px solid rgba(255, 230, 150, 0.35);
    font-weight: 800;
    letter-spacing: 0.6px;
    transform: translateY(0);
}

#playOnlineBtn:hover:not(:disabled) {
    filter: brightness(1.05);
    transform: translateY(-1px);
}

#headerNewOnlineBtn {
    background: linear-gradient(
        90deg,
        #67155d 0%,
        #129330 30%,
        #ff9f1a 100%
    );
    color: #2a1b00 !important;
    border-color: rgba(255, 230, 150, 0.35) !important;
    box-shadow: 0 8px 18px rgba(255, 165, 0, 0.3);
    font-weight: 800;
    letter-spacing: 0.6px;
    min-height: 42px;
    min-width: clamp(106px, 12.5vw, 166px);
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    line-height: 1;
    font-size: clamp(0.66rem, 1.28vw, 0.9rem);
}

#headerRefreshStateBtn {
    width: 42px;
    min-width: 42px;
    height: 42px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #d43636;
    color: #fff;
    border-color: #ef6666;
    font-size: 1.2rem;
    font-weight: 800;
    line-height: 1;
}

#headerRefreshStateBtn:hover {
    background: #c52c2c;
}

.match-invite-toast {
    position: fixed;
    top: 16px;
    right: 16px;
    background: rgba(18, 18, 18, 0.95);
    border: 1px solid rgba(255, 204, 51, 0.35);
    color: #f5f5f5;
    padding: 10px 12px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 300001;
    pointer-events: none;
}

.match-invite-toast.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.match-invite-toast.centered {
    left: 50%;
    right: auto;
    transform: translate(-50%, -6px);
}

.match-invite-toast.centered.show {
    transform: translate(-50%, 0);
}

.match-invite-icon {
    font-size: 16px;
}

.match-invite-join {
    background: #ffcc33;
    color: #2a1b00;
    border: 0;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 800;
    font-size: 11px;
}
.mode-btn:hover:not(:disabled) { background: #6bb8ff; }
.mode-btn:disabled {
    background: #444;
    cursor: not-allowed;
    color: #888;
}

#auth-overlay, #users-overlay, #rules-overlay, #profile-overlay, #match-preferences-overlay, #live-matches-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5); /* Sfondo semi-trasparente per vedere il gioco */
    display: none; 
    justify-content: center;
    align-items: center;
    z-index: 300000;
    backdrop-filter: blur(4px); /* Blur leggermente ridotto per visibilità background */
    animation: fadeIn 0.3s ease;
}

/* Iframe di login piccolo e centrato */
#auth-frame {
    width: 360px;
    height: 480px;
    background: #1a1a1a;
    border: 2px solid #ff1e32;
    border-radius: 20px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
    z-index: 300002;
    overflow: hidden;
}

#users-overlay, #rules-overlay, #profile-overlay, #match-preferences-overlay, #live-matches-overlay { background: rgba(0, 0, 0, 0.85); z-index: 300000; }

#users-container, #rules-container, #profile-container, #match-preferences-container, #contact-container, #live-matches-container {
    width: 90%;
    max-width: 800px;
    height: 80vh;
    background: var(--card);
    border-radius: 20px;
    position: relative;
    border: 1px solid #444;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9);
    z-index: 300001;
}

#rules-container { max-width: 900px; height: 88vh; }
#rules-container .close-btn-overlay { display: none; }
#live-matches-container { max-width: 980px; height: 86vh; }
#match-preferences-container {
    max-width: 860px;
    height: auto;
    max-height: 86vh;
    overflow-y: auto;
    padding: 22px 24px;
}

.match-prefs-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-top: 8px;
}

.match-prefs-content h3 {
    margin: 0;
    color: var(--p2);
    font-size: 20px;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

.match-prefs-subtitle {
    margin: 0;
    color: #b7c0ce;
    font-size: 13px;
    letter-spacing: 0.4px;
}

.match-pref-row {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.match-pref-row label {
    color: #d9e1ef;
    font-size: 12px;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

.prefs-slicer {
    width: fit-content;
    max-width: 100%;
    flex-wrap: wrap;
}

.match-prefs-advanced {
    border-top: 1px solid rgba(255,255,255,0.1);
    margin-top: 8px;
    padding-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

iframe {
    width: 100%;
    height: 100%;
    border: 0;
    background-color: var(--card) !important;
}

.close-btn-overlay {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: 0;
    color: #888;
    font-size: 22.4px;
    cursor: pointer;
    z-index: 10;
    transition: color 0.2s;
}

.close-btn-overlay:hover { color: white; }

body.spectator-mode #game-area,
body.spectator-mode #pool,
body.spectator-mode #active-piece-overlay,
body.spectator-mode #piece-filters {
    pointer-events: none !important;
}

body.spectator-mode #piece-filters,
body.spectator-mode .filter-row,
body.spectator-mode #side-controls,
body.spectator-mode .player2-mode,
body.spectator-mode #player2-mode {
    display: none !important;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(1.05); }
    to { opacity: 1; transform: scale(1); }
}

/* --- FOOTER & POOL --- */
.footer { 
    background: #1e1f22; /* antracite */
    display: flex; 
    flex-direction: column; 
    align-items: stretch; 
    border-top: none; /* rimosso il bordo per eliminare la linea di separazione */
    position: relative;
    flex: 0 0 auto;
    flex-shrink: 0;
    margin: 0;
    max-height: none;
    height: auto;
    overflow: hidden;
    padding-bottom: 0;
    pointer-events: auto;
    margin-bottom: var(--shop-banner-height);
}

#choose-label {
    margin: 0;
    color: var(--text);
    font-size: 14px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
    padding: 4px 12px;
    border-radius: 20px;
    width: 100%;
    text-align: center;
    display: block;
}

.place-it-msg {
    color: #ffeb3b !important;
    text-shadow: none;
    opacity: 0;
    margin-top: 16px;
}

.place-it-msg.show {
    animation: chooseNextFade 8.1s ease forwards;
}

#logo {
    position: absolute;
    top: 0.5em;
    left: 0.5em;
    width: 3em;
    height: 3em;
    cursor: pointer;
    z-index: 9999; /* Bring logo in front of everything */
}

.choose-next-msg {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: #ffeb3b;
    font-weight: 800;
    font-size: 17px;
    letter-spacing: 2px;
    text-transform: uppercase;
    opacity: 0;
    pointer-events: none;
    text-shadow: none;
    white-space: nowrap;
}

.choose-next-msg.show {
    animation: chooseNextFade 8.1s ease forwards;
}

@keyframes chooseNextFade {
    0% { opacity: 0; }
    10% { opacity: 1; }
    27% { opacity: 1; }
    75% { opacity: 0.25; }
    100% { opacity: 0; }
}

.mini { 
    width: 34px;
    height: 34px;
    border-radius: 5px;
    background: #222;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22.5px;
    font-weight: bold;
    margin: 2px 4px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 2px solid #333;
    transition: transform 0.12s, box-shadow 0.18s;
    flex-shrink: 0;
}

.mini.disabled {
    opacity: 0.25;
    filter: grayscale(50%);
    pointer-events: none;
}

/* --- STATS BAR --- */
.stats-bar {
    width: 100vw;
    /* Full-bleed bar aligned to viewport (independent from parent centering/padding) */
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    box-sizing: border-box;
    display: flex;
    justify-content: flex-start;
    gap: 12px;
    padding: 0 var(--stats-edge-gap) 0 0;
    padding-left: 0;
    background: rgba(255, 255, 255, 0.03);
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-top: 1px solid #222;
    position: relative;
    bottom: auto;
    height: var(--stats-bar-height);
    align-items: center;
    z-index: 999;
    overflow: hidden;
    align-self: stretch;
}

.stats-item {
    display: flex;
    /*align-items: center;*/
    align-items: flex-start;
    text-align: left;
}

.stats-bar > .stats-item:not(#connectedCounter) {
    margin-left: auto;
}

.stats-bar > * {
    position: relative;
    z-index: 2;
}

.choose-timer-bar {
    position: absolute;
    justify-content: flex-start;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    pointer-events: none;
    z-index: 1;
}

.choose-timer-bar.show {
    opacity: 0.85;
}

.choose-timer-bar.is-ending .choose-timer-fill {
    animation: chooseTimerPulse 0.6s ease-in-out infinite;
}

.choose-timer-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, rgba(255, 215, 0, 0) 0%, rgba(255, 215, 0, 1) 100%);
    transition: width 0.15s linear;
}

@keyframes chooseTimerPulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.stats-item.clickable {
    cursor: pointer;
    transition: color 0.2s;
}

.stats-item.clickable:hover { color: #fff; }

#connectedCounter {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    justify-content: flex-start;
    text-align: left;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: calc(var(--stats-edge-gap) + 0.8vw);
    inset-inline-start: 0;
    margin: 0;
    padding-left: 0;
    padding-right: 0;
    z-index: 3;
}

#connectedText {
    text-align: left;
}


.stats-laser {
    position: absolute;
    top: 0;
    left: -12%;
    width: 12%;
    height: 100%;
    background: linear-gradient(90deg, rgba(255,235,59,0) 0%, rgba(255,235,59,0.85) 42%, rgba(255,255,240,1) 50%, rgba(255,235,59,0.85) 58%, rgba(255,235,59,0) 100%);
    box-shadow: 0 0 36px rgba(255, 235, 59, 1);
    opacity: 0;
    pointer-events: none;
}

/* Disable bright sweep that can appear as a white flash */
.stats-laser,
.stats-laser.active {
    display: none;
    animation: none;
}

.dot-online {
    margin: 0;
    display: inline-block;
    width: 7px;
    height: 7px;
    background: #00ff00;
    border-radius: 50%;
    margin-right: 5px;
    box-shadow: 0 0 5px #00ff00;
}

/* --- SHOP BANNER --- */
.shop-banner { 
    width: 100%; 
    background: #ffd700; /* giallo fisso */
    color: #cc0000; 
    text-decoration: none; 
    display: flex; 
    justify-content: center;
    align-items: center;
    height: var(--shop-banner-height);
    border-top: none;
    cursor: pointer; 
    transition: background 0.2s;
    position: fixed; /* Lo rende fisso rispetto alla finestra */
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;  /* Sopra tutto */
    flex-shrink: 0;
    margin: 0;
}

.shop-banner:hover { background: #ffdb4d; }

.ai-power-tooltip {
    position: fixed;
    z-index: 12000;
    pointer-events: none;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.14s ease, transform 0.14s ease;
    background: rgba(0, 0, 0, 0.86);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 7px;
    padding: 6px 9px;
    font-size: 11px;
    line-height: 1.2;
    white-space: nowrap;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}

.ai-power-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

.ai-power-tooltip.is-learning {
    color: #ff4b4b;
}

/* --- SWITCH E CONTROLLI --- */
#side-controls {
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 10070;
    pointer-events: auto;
}

#side-controls .switch,
#side-controls .slider,
#side-controls .mode-label {
    pointer-events: auto;
}

.switch { position: relative; display: inline-block; width: 50px; height: 80px; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #555; transition: .4s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 42px; width: 42px; left: 4px; bottom: 4px; background-color: #ddd; transition: .4s; border-radius: 50%; }
.switch input:checked + .slider { background-color: var(--p1); }
.switch input:checked + .slider:before { transform: translateY(-30px); }

.mode-slicer .mode-label {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    pointer-events: none;
    transition: opacity 0.2s ease, font-weight 0.2s ease, top 0.2s ease, bottom 0.2s ease;
}

.mode-slicer .mode-label-pro {
    color: #ff3b3b;
    font-weight: 800;
    font-size: 11px;
}

.mode-slicer .mode-label-casual {
    color: #ff3b3b;
    font-weight: 700;
    font-size: 9px;
}

/* Default (Casual selected): CASUAL inside knob, PRO in free area above */
.mode-slicer input:not(:checked) + .slider .mode-label-casual {
    left: 4px;
    bottom: 4px;
    width: 42px;
    height: 42px;
    transform: none;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    color: #4caf50;
}
.mode-slicer input:not(:checked) + .slider .mode-label-pro {
    top: 6px;
    opacity: 1;
    color: #ff3b3b;
}

/* PRO selected: PRO inside knob, CASUAL in free area below */
.mode-slicer input:checked + .slider .mode-label-pro {
    left: 4px;
    top: 4px;
    width: 42px;
    height: 42px;
    transform: none;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    color: #4caf50;
}
.mode-slicer input:checked + .slider .mode-label-casual {
    bottom: 6px;
    opacity: 1;
    color: #7b1e3a;
    font-size: 9.72px;
    transform: translate(-50%, -20%);
}

.available-pieces {
    position: relative;
    z-index: 9001;
}
/* --- AREA POOL + FILTRI --- */
.pool-area {
    width: 100%;
    display: flex;
    max-height: none;
    overflow: hidden;
}

.pool-col {
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}

.filter-row {
    display: flex;
    align-items: center;
    gap: clamp(2px, 0.65vw, 8.1px);
    justify-content: center;
    margin-bottom: 2.7px;
    align-self: center;
    width: 100%;
    max-width: 100%;
    flex-wrap: nowrap;
    overflow: hidden;
    white-space: nowrap;
}

.piece-filters {
    display: flex;
    flex-wrap: nowrap;
    gap: clamp(2px, 0.65vw, 8.1px);
    justify-content: center;
    align-items: center;
    width: 100%;
    min-width: 0;
}

.filter-btn {
    width: clamp(18px, 5vw, 27.9px);
    height: clamp(18px, 5vw, 27.9px);
    border-radius: 50%;
    border: clamp(1px, 0.35vw, 1.8px) solid #333;
    background: var(--dot, #222);
    color: #eee;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(8px, 2.2vw, 12.6px);
    font-weight: bold;
    transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
    flex: 0 0 auto;
}

.filter-btn:hover { transform: scale(1.06); }

.filter-btn.is-off {
    opacity: 0.35;
    filter: grayscale(50%);
}

.filter-symbol { line-height: 1; }

.filter-action {
    background: rgba(255,255,255,0.04);
    color: #ccc;
    border: 1px solid rgba(255,255,255,0.12);
    padding: clamp(1.5px, 0.55vw, 4.5px) clamp(4px, 1.4vw, 8.1px);
    border-radius: clamp(8px, 2.4vw, 14.4px);
    font-size: clamp(7px, 1.9vw, 9px);
    text-transform: uppercase;
    letter-spacing: 0.54px;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.15s, border-color 0.2s, color 0.2s;
    flex: 0 0 auto;
}

.filter-action:hover { transform: translateY(-1px); color: #fff; }

.filter-action.active {
    border-color: var(--p1);
    color: #fff;
    background: var(--p1);
    box-shadow: 0 6px 14px rgba(255,71,87,0.18);
}

/* --- LIVELLI E TESTI --- */
.level-column { text-align: center; }
.level-title { margin-bottom: 10px; font-size: 12px; color: #888; font-weight: bold; }

.lvl-dots { display: none; }
.dot { display: none; }

/* Player2 compact slicer styles */
.slicer { display:inline-flex; background: rgba(255,255,255,0.03); border-radius:28px; padding:6px; border:1px solid rgba(255,255,255,0.06); max-width:220px; box-sizing: border-box; position: relative; z-index: 10060; pointer-events: auto; }
.slicer { border-radius:23px; padding:4.5px; max-width:178px; }
.slicer-seg { background: transparent; color: #bbb; padding:8px 12px; border:0; border-radius:14px; cursor:pointer; font-size:0.85rem; min-width:45px; text-align:center; font-weight:700; position: relative; z-index: 10061; pointer-events: auto; }
.slicer-seg.active { background: var(--p2); color: #fff; box-shadow: 0 6px 18px rgba(84,160,255,0.24); border: 1px solid rgba(255,255,255,0.08); }
/* ensure slicer fits inside player-ui */
.player-ui { overflow: hidden; }

@media (max-width: 640px) {
    .slicer-seg { padding:6px 8px; font-size:10px; min-width:39px; }
    .slicer { max-width:130px; }
}
.player2-mode {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 2px;
}
.lvl-stars-row {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 23px;
}
.lvl-stars {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}
.p2-controls[hidden] { display:none; }

/* Level stars */
.lvl-star { background: transparent; border:0; color: #555; font-size:13.9px; cursor:pointer; padding:5px; border-radius:6px; }
.lvl-star.active { color: #4fb0ff; text-shadow: 0 4px 12px rgba(79,176,255,0.18); }
.lvl-star:focus { outline: 2px solid rgba(79,176,255,0.12); }
.lvl-star.learning-star { color: #7b2b2b; }
.lvl-star.learning-star.active { color: #ff4b4b; text-shadow: 0 4px 12px rgba(255,75,75,0.28); }
.lvl-star.learning-star:disabled,
.lvl-star.learning-star[aria-disabled="true"] {
    opacity: 0.38;
    cursor: not-allowed;
    text-shadow: none;
}

/* --- ACTIVE PIECE OVERLAY (3D) --- */
#active-piece-overlay {
    position: absolute;
    top: 0; 
    right: 0; 
    display: none; 
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none; 
    z-index: 100;
    background: transparent;
    padding: 15px;
    border-radius: 11px;
}

#active-piece-overlay.visible { display: flex; }

#active-piece-overlay.turn-place-flash,
#next-display-2d.turn-place-flash {
    --place-turn-color: #54a0ff;
    border: 1.5px solid color-mix(in srgb, var(--place-turn-color) 70%, transparent);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--place-turn-color) 22%, transparent) inset;
    animation: placeTurnBorderFlash 5s linear infinite;
}

@keyframes placeTurnBorderFlash {
    0%, 82%, 100% {
        border-color: color-mix(in srgb, var(--place-turn-color) 22%, transparent);
        box-shadow:
            0 0 0 1px color-mix(in srgb, var(--place-turn-color) 15%, transparent) inset,
            0 0 0 rgba(0, 0, 0, 0);
    }
    86% {
        border-color: color-mix(in srgb, var(--place-turn-color) 95%, white 5%);
        box-shadow:
            0 0 0 1px color-mix(in srgb, var(--place-turn-color) 55%, transparent) inset,
            0 0 12px color-mix(in srgb, var(--place-turn-color) 65%, transparent),
            0 0 24px color-mix(in srgb, var(--place-turn-color) 42%, transparent);
    }
    92% {
        border-color: color-mix(in srgb, var(--place-turn-color) 30%, transparent);
        box-shadow:
            0 0 0 1px color-mix(in srgb, var(--place-turn-color) 18%, transparent) inset,
            0 0 4px color-mix(in srgb, var(--place-turn-color) 22%, transparent);
    }
}

#canvas-active {
    width: 108px;
    height: 108px;
    filter: drop-shadow(0 0 20px rgba(0,0,0,0.5)); 
}

/* --- AI FACE OVERLAY --- */
#ai-face-overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 226px;
    height: 226px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    opacity: 0;
    transform: translateY(6px) scale(0.98);
    transition: opacity 0.35s ease, transform 0.35s ease;
    pointer-events: none;
    z-index: 120;
}

#ai-face-overlay.rematch-prompt {
    pointer-events: auto;
}

#ai-face-overlay.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

#ai-face-frame {
    width: 176px;
    height: 176px;
    border: 0;
    border-radius: 12px;
    background: transparent !important;
    background-color: transparent !important;
    box-shadow: none;
}

.ai-rematch-bubble {
    position: absolute;
    right: calc(100% - 18px);
    top: 16px;
    min-width: 168px;
    max-width: 240px;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(12, 14, 18, 0.88);
    border: 1px solid rgba(84,160,255,0.55);
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    color: #fff;
    font-weight: 700;
    text-align: center;
    pointer-events: auto;
}

.ai-rematch-bubble::after {
    content: "";
    position: absolute;
    right: -8px;
    top: 22px;
    width: 0;
    height: 0;
    border-top: 7px solid transparent;
    border-bottom: 7px solid transparent;
    border-left: 8px solid rgba(84,160,255,0.55);
}

#ai-face-overlay.rematch-prompt .ai-rematch-bubble {
    display: flex;
}

.ai-rematch-ok {
    min-width: 72px;
    max-width: none;
    width: auto;
    padding: 7px 12px;
    font-size: 0.72rem;
}

.place-label {
    margin-top: 10px;
    color: var(--text);
    font-size: 14px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
    padding: 4px 12px;
    border-radius: 20px;
}

.piece-display { display: none; }
.piece-display.active2d {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
}

.drop-box { 
    width: 54px; height: 54px; 
    background: #333; border-radius: 10px; 
    display: flex; align-items: center; justify-content: center; 
    font-size: 17.6px; font-weight: bold; border: 2px dashed #555;
}

@media (max-width: 720px) {
    #ai-face-overlay {
        top: 8px;
        right: 8px;
        width: 182px;
        height: 182px;
        padding: 18px;
    }
    #ai-face-frame {
        width: 140px;
        height: 140px;
    }
    .ai-rematch-bubble {
        right: calc(100% - 10px);
        top: 10px;
        min-width: 146px;
        padding: 8px 10px;
        font-size: 12px;
    }
}

/* --- FIX POSIZIONAMENTO E MOBILE --- */
@media (min-width: 1200px) {
    .nav-row {
        gap: 5px;
    }
    .scoreboard {
        gap: 0;
        padding: 0;
    }
    .player-ui {
        min-width: 120px;
    }
    .p1-name, .p2-name {
        font-size: 1rem;
    }
}

/* Toast messages */
.terxo-toast {
    background: rgba(20,20,20,0.95);
    color: #fff;
    padding: 12px 18px;
    border-radius: 12px;
    box-shadow: 0 6px 22px rgba(0,0,0,0.6);
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    font-weight: 600;
    pointer-events: none;
}
.terxo-toast.visible { opacity: 1; transform: translateY(0); }

/* --- POOL LAYOUT: keep slicer left of pieces --- */
.pool-area {
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    flex-wrap: nowrap;
}

#side-controls {
    flex: 0 0 auto;
    transform: scale(0.72);
    transform-origin: left center;
}

.pool-col {
    flex: 1 1 0;
    align-items: center;
}

.pool-col .filter-row,
.pool-col .piece-filters,
.pool-col #pool {
    width: 100%;
    justify-content: center;
}

