:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #64748b;
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #10b981;
    --font-main: 'Outfit', sans-serif;
    --font-mono: 'Roboto Mono', monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 0;
}

/* Stile personalizzato per la scrollbar interna */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.3); /* Colore var(--primary) semitrasparente */
    border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.5);
}

.glass-container {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
		min-height: 94vh; 
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--glass-border);
    border-radius: 32px;
    padding: 30px;
    width: 98%;
    max-width: 1300px; /* Allargato per ospitare Grid, LB e Matrix */
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
}

.play-content {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    justify-content: space-between;
    gap: 30px;
    margin-bottom: 25px;
    width: 100%;
    max-width: 1200px; /* Allineato all'allargamento del container */
    margin: 0 auto 25px auto;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

.main-title {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 5px;
    background: linear-gradient(to right, #818cf8, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.subtitle {
    font-size: 1.2rem;
    color: var(--text-muted);
    font-weight: 300;
    margin-bottom: 25px;
    letter-spacing: 1px;
}

#timer {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--accent);
}

#game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 15px;
    margin: 0; /* Allineato a sinistra del parent */
}

.crypto-grid {
    display: grid;
    /* 5 colonne: Num(95px) Op(20px) Num(95px) Eq(20px) Result(95px) */
    grid-template-columns: 95px 20px 95px 20px 95px;
    gap: 4px 10px;
    justify-content: center;
    align-items: center;
    background: rgba(0,0,0,0.3);
    padding: 15px;
    border-radius: 20px;
    width: fit-content;
}

.cell {
    width: 95px; 
    height: 70px; 
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    padding: 2px 4px; /* Ridotto padding per far star 3 icone */
}

/* Ridimensionamento icone specifico per la griglia */
.cell .symbol-wrapper {
    width: 28px !important;
    height: 28px !important;
}

.cell .symbol-img, 
.cell .symbol-placeholder {
    width: 24px !important;
    height: 24px !important;
    font-size: 1.1rem !important;
}

.cell:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.2);
}

.cell.operator, .cell.equals {
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    font-size: 1.4rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center; /* Centrati di base (per le righe 1, 2, 3) */
    cursor: default;
    box-shadow: none;
}

/* Solo quelli tra una riga e l'altra si allineano a destra per incolonnamento */
.cell.operator.vertical, .cell.equals.vertical {
    justify-content: flex-end !important; /* Forza allineamento a destra */
    padding-right: 1px !important;
}

.vertical-ops .cell.operator {
    width: 75px; /* Sincronizzato con larghezza .cell */
}

.cell.equals.vertical {
    border-radius: 8px; /* Solo per dare una forma minima se necessario */
}

.symbol-container {
    display: flex;
    gap: 2px;
    justify-content: flex-end; 
    padding-right: 1px; /* Ridotto al minimo assoluto */
}

.symbol-wrapper {
    position: relative;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.symbol-wrapper:hover {
    transform: scale(1.15);
    filter: brightness(1.2);
}

.symbol-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 2;
    background: transparent;
}

/* Icona di fallback generata se l'immagine manca */
.symbol-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem; /* Icone più grandi */
    color: white;
    z-index: 1;
    box-shadow: inset 0 0 10px rgba(255,255,255,0.4);
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Colori personalizzati per i simboli */
.sym-color-0 { background: #ef4444; } /* Red */
.sym-color-1 { background: #a7f3d0; } /* Diamante: Verdino (#a7f3d0) */
.sym-color-2 { background: #10b981; } /* Green */
.sym-color-3 { background: #06b6d4; } /* Pacco: Celeste (#06b6d4) */
.sym-color-4 { background: #fbbf24; } /* Fiore: Giallo (#fbbf24) */
.sym-color-5 { background: #ec4899; } /* Pink */
.sym-color-6 { background: #3b82f6; } /* Cuffia: Blu (#3b82f6) */
.sym-color-7 { background: #84cc16; } /* Lime */
.sym-color-8 { background: #22c55e; } /* Mela: Verde (#22c55e) */
.sym-color-9 { background: #f472b6; } /* Uva: Rosa (#f472b6) */

.digit-display-small {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent);
    min-height: 1.1em;
    text-shadow: 0 0 5px rgba(16, 185, 129, 0.3);
    text-align: right;
    margin-right: 1px;
}

.symbol-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

/* Controlli */
footer .controls {
    display: flex;
    gap: 15px;
}

.btn {
    flex: 1;
    padding: 14px;
    border-radius: 12px;
    border: none;
    font-family: var(--font-main);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn.primary {
    background: var(--primary);
    color: white;
}

.btn.primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn.secondary {
    background: var(--secondary);
    color: white;
}

/* Modale */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s;
}

#alert-modal { z-index: 5000 !important; }

.modal.hidden {
    display: none;
    pointer-events: none;
}

.modal-content {
    background: #1e293b;
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    border: 1px solid var(--glass-border);
    max-width: 320px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}

.difficulty-modal-content {
    max-width: 400px;
}

.difficulty-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.difficulty-btn {
    text-align: left;
    padding: 12px 20px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.difficulty-btn:hover {
    background: var(--primary);
    transform: translateX(5px);
}

.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 20px 0;
}

.num-btn {
    padding: 15px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: background 0.2s;
}

.num-btn:hover {
    background: var(--primary);
}

.num-btn.clear {
    grid-column: span 2;
    background: rgba(239, 68, 68, 0.2);
}

.num-btn.clear:hover {
    background: #ef4444;
}

/* Legenda */
.legend-box {
    margin-top: 30px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 20px;
    width: 100%;
    max-width: 850px; /* Sincronizzato con play-area */
    margin: 30px auto;
    animation: fadeIn 0.5s ease-out;
}

.legend-box h3 {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 15px;
    text-align: center;
}

.legend-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 10px;
}

.legend-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    background: rgba(0,0,0,0.2);
    padding: 10px;
    border-radius: 12px;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.legend-item.active {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.legend-item .symbol-img {
    width: 24px;
    height: 24px;
}

.legend-val {
    font-weight: 700;
    color: var(--accent);
}

#symbols-legend.legend-grid {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    justify-content: center;
    overflow-x: auto;
    max-width: 100vw;
}

#symbols-legend .legend-item {
    width: 55px;
    height: 55px;
    padding: 5px;
    justify-content: center;
    flex-shrink: 0;
}

/* Matrice di Esclusione */
.matrix-box {
    margin-top: 0;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 8px; /* Ridotto */
    max-width: 380px; 
}

.logic-matrix {
    display: flex;
    flex-direction: column;
    gap: 1px; /* Compattazione verticale totale */
}

.matrix-row {
    display: flex;
    align-items: center;
    gap: 4px; 
    height: 28px; /* Alzata a 28px */
}

.matrix-label {
    width: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 28px;
}

/* Fondamentale: sovrascrive il wrapper da 36px */
.matrix-label .symbol-wrapper {
    width: 28px !important;
    height: 28px !important;
    padding: 0 !important;
    border-radius: 6px !important;
}

.matrix-label .symbol-img, 
.matrix-label .symbol-placeholder {
    width: 26px !important;
    height: 26px !important;
    font-size: 1rem !important;
}

.matrix-cells {
    display: flex;
    gap: 2px;
    flex: 1;
}

.matrix-cell {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    border-radius: 4px; 
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    color: #ffffff;
}

.matrix-cell:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.matrix-cell.excluded {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    text-decoration: line-through;
    opacity: 0.5;
}

.matrix-cell.confirmed {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    font-weight: 800;
    border-color: #10b981;
}

/* Altri stili */
.hidden { display: none !important; }

/* QR Panel Layout */
.qr-panel {
    display: flex;
    gap: 25px;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
}

@media (max-width: 650px) {
    .qr-panel {
        flex-direction: column;
        text-align: center !important;
    }
    .qr-panel > div:last-child {
        text-align: center !important;
    }
    .qr-panel .btn {
        margin-top: 10px;
    }
}
/* Modal Alert/Confirm Custom */
.alert-modal-content {
    max-width: 400px;
    padding: 25px;
}

.alert-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    display: block;
}

.alert-title {
    font-size: 1.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

.alert-message {
    color: var(--text-muted);
    margin-bottom: 25px;
    line-height: 1.6;
}

.alert-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.alert-actions .btn {
    flex: 1;
    min-width: 100px;
}

.type-success .alert-icon { color: var(--accent); }
.type-error .alert-icon { color: #f87171; }
.type-warning .alert-icon { color: #fbbf24; }
.type-info .alert-icon { color: var(--primary); }

.alert-modal-content.type-success { border-color: var(--accent); }
.alert-modal-content.type-error { border-color: #f87171; }

.alert-modal-content.type-rush { 
    background: #450a0a !important; 
    border-color: #ef4444 !important; 
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.4) !important;
}
.type-rush .alert-icon { color: #fca5a5; }
.type-rush .alert-title { color: #fef2f2; }
.type-rush .alert-message { color: #fee2e2; }


/* --- Rush Time Styles (Allarme Tempo Scaduto) --- */
@keyframes pulse-fast {
    0% { opacity: 1; text-shadow: 0 0 10px rgba(239, 68, 68, 0.5); }
    50% { opacity: 0.3; text-shadow: 0 0 25px rgba(239, 68, 68, 1); }
    100% { opacity: 1; text-shadow: 0 0 10px rgba(239, 68, 68, 0.5); }
}

.rush-time {
    color: #ef4444 !important;
    animation: pulse-fast 0.8s ease-in-out infinite;
    transition: all 0.3s;
}

/* Tiny Loader for buttons */
.loader-tiny {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin-tiny 0.8s linear infinite;
    display: inline-block;
    vertical-align: middle;
}
@keyframes spin-tiny {
    to { transform: rotate(360deg); }
}

.rotation-slow {
    animation: rotation-slow 2s infinite linear;
}

@keyframes rotation-slow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Phase 2: Management & Live UI */
.player-chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 20px;
    margin: 5px;
    cursor: pointer;
    transition: all 0.2s;
}

.player-chip:hover {
    background: rgba(239,68,68,0.2);
    border-color: #ef4444;
}

.player-chip .player-score {
    font-weight: 800;
    color: var(--accent);
    font-size: 0.8rem;
}

.mini-progress-bar {
    width: 40px;
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    overflow: hidden;
}

.mini-progress-bar div {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s;
}

.live-leaderboard-container {
    width: 250px;
    padding: 20px;
    position: sticky;
    top: 20px;
}

.live-player-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.9rem;
}

.live-player-row .rank {
    font-weight: 800;
    color: var(--text-muted);
    width: 25px;
}

.live-player-row .name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 5px;
}

.live-player-row .score {
    font-weight: 800;
    color: var(--accent);
}

@media (max-width: 800px) {
    .play-content { flex-direction: column !important; }
    .live-leaderboard-container { width: 100%; position: static; order: 3; }
}

.revealed-item {
    border-color: rgba(16, 185, 129, 0.7);
    background: rgba(16, 185, 129, 0.10);
    box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.15);
}

.revealed-item .legend-val,
.revealed-digit {
    color: #10b981;
    font-weight: 800;
}

.legend-item.is-helped {
    border-color: #fbbf24 !important;
    background: rgba(251, 191, 36, 0.15) !important;
    box-shadow: 0 0 15px rgba(251, 191, 36, 0.3) !important;
}

.legend-item.is-helped .legend-val {
    color: #fcd34d !important;
}

.symbol-wrapper.is-helped {
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.6);
    border-radius: 50%;
    animation: helped-pulse 2s infinite;
}

@keyframes helped-pulse {
    0% { box-shadow: 0 0 8px rgba(251, 191, 36, 0.4); }
    50% { box-shadow: 0 0 16px rgba(251, 191, 36, 0.8); }
    100% { box-shadow: 0 0 8px rgba(251, 191, 36, 0.4); }
}

/* --- Landing Page Styles --- */
.landing-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 40px;
    padding: 0 10px;
}

.nav-logo {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--text);
    background: linear-gradient(to right, #818cf8, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.menu-cards {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 30px;
    margin-top: 30px;
    width: 100%;
}

.menu-card {
    flex: 1;
    min-width: 280px;
    max-width: 400px;
    padding: 30px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    text-align: left;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.menu-card:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

.menu-card h3 {
    font-size: 1.5rem;
    margin-bottom: 12px;
    color: var(--text);
}

.menu-card p {
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1.5;
}

.input-dark {
    width: 100%;
    padding: 12px 15px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: #f8fafc;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: all 0.2s;
}

.input-dark:focus {
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.3);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.btn.outline {
    background: transparent;
    border: 1px solid var(--secondary);
}

.btn.outline:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--text);
}

.landing-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}
.hidden { display: none !important; }

/* Master Live Console Rows */
.master-table-row {
    display: grid;
    grid-template-columns: 50px 1.5fr 2fr 80px 70px 90px 40px;
    align-items: center;
    padding: 8px 15px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    transition: all 0.2s ease;
}

.master-table-row:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.2);
}

.mtr-cell {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.mtr-rank {
    font-weight: 800;
    color: var(--text-muted);
}

.mtr-action .kick-btn {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s;
    font-size: 0.9rem;
    padding: 5px;
}

.mtr-action .kick-btn:hover {
    opacity: 1;
}

.badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    display: inline-block;
    text-align: center;
}

@media (max-width: 800px) {
    .master-table-header { display: none !important; }
    .master-table-row {
        grid-template-columns: auto 1fr auto;
        gap: 10px;
        padding: 15px;
    }
    .mtr-rank { font-size: 1.2rem; margin-right: 10px; }
    .mtr-action { grid-column: 3; grid-row: 1; }
    .mtr-progress { grid-column: 1 / -1; grid-row: 2; margin: 10px 0; }
    .mtr-score, .mtr-time, .mtr-status { grid-row: 3; font-size: 0.85rem; }
    .mtr-score { grid-column: 1; }
    .mtr-time { grid-column: 2; text-align: center; }
    .mtr-status { grid-column: 3; text-align: right; }
}

/* Master Dashboard Two Column Layout */
.dashboard-layout {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 30px;
    width: 100%;
    margin-top: 10px;
    flex: 1;          /* occupa tutto lo spazio rimasto nel flex-column del container */
    min-height: 0;    /* permette di restringersi sotto min-content */
    overflow: hidden;
}

.dashboard-sidebar {
    width: 420px;
    flex-shrink: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 6px;   /* Spazio per la scrollbar */
}

.dashboard-sidebar::-webkit-scrollbar {
    width: 6px;
}
.dashboard-sidebar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}
.dashboard-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 10px;
}
.dashboard-sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.22);
}

.dashboard-main {
    flex-grow: 1;
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Scrollbar styling for the players list */
.scrollable-players::-webkit-scrollbar {
    width: 8px;
}
.scrollable-players::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}
.scrollable-players::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}
.scrollable-players::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

@media (max-width: 1024px) {
    .dashboard-layout {
        flex-direction: column;
    }
    .dashboard-sidebar {
        width: 100%;
        position: relative;
        top: 0;
        height: auto;
    }
    .scrollable-players {
        max-height: none !important;
        overflow-y: visible !important;
    }
}

/* Overrides specifici per la Master Dashboard */
.master-glass-container {
    min-height: 0 !important;
    height: calc(100vh - 40px) !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
}

/* Quando è presente la master dashboard, il body non deve centrare verticalmente */
body:has(.master-glass-container) {
    align-items: flex-start;
    padding: 20px 0;
}


/* --- RIDUZIONE BORDI CONTAINER PRINCIPALE --- */
.glass-container {
    padding: 15px !important; /* Riduce i bordi spessi del container */
    max-width: 1100px !important; /* Misura ideale per tenere tutto compatto senza praterie centrali */
    margin: 0 auto;
}

/* --- LAYOUT DI GIOCO DEFINITIVO --- */
.game-core-layout {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap; 
    justify-content: center; 
    align-items: flex-start;
    gap: 30px; /* Distanza pulita tra colonna destra e sinistra */
    width: 100%; 
    margin: 0 auto;
}

/* Colonna Schema: Fissata a 480px per allineare schema e barra */
.game-col-interactive {
    flex: 0 1 auto; 
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center; 
    width: 100%;
    max-width: 480px; /* Allargato a 480px */
}

/* Colonna Strumenti: Fissata per la matrice */
.game-col-tools {
    flex: 0 1 auto; 
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center; 
    width: 100%;
    max-width: 380px; 
}

/* VETRI: Occupano il 100% della loro colonna "bloccata" */
#game-container, #matrix-container, .legend-box, #live-leaderboard {
    margin: 0 !important;
    padding: 15px !important;
    box-sizing: border-box;
    width: 100% !important; 
}

/* BARRA SIMBOLI SU UNA RIGA - SENZA BOX */
#symbols-legend.legend-grid {
    display: flex;
    flex-wrap: nowrap !important; /* Forza la singola riga */
    justify-content: space-between; /* Spazia i simboli uniformemente */
    gap: 2px; /* Gap ridotto al minimo, lo spazio lo crea il justify-content */
    width: 100%;
}

#symbols-legend .legend-item {
    flex: 0 0 auto !important;
    width: 38px !important; /* Stretti il giusto per farne stare 11 in 480px */
    height: 52px !important;
    padding: 2px !important; 
    justify-content: center;
    gap: 4px;
    background: transparent !important; /* Rimuove il box di sfondo */
    border: none !important; /* Rimuove il bordo */
    box-shadow: none !important;
}

/* Effetto hover delicato senza ripristinare il box intero */
#symbols-legend .legend-item:hover,
#symbols-legend .legend-item.active {
    background: rgba(255, 255, 255, 0.05) !important;
    border-radius: 8px;
}

#symbols-legend .legend-item .symbol-img,
#symbols-legend .legend-item .symbol-placeholder {
    width: 26px !important; /* Leggermente più grandi per risaltare senza il box */
    height: 26px !important;
    font-size: 1rem !important;
}

#symbols-legend .legend-item .legend-val {
    font-size: 0.95rem; /* Numero ben leggibile */
}

/* Layout Cellulare / Schermi stretti */
@media (max-width: 950px) {
    .game-core-layout {
        gap: 25px; 
    }
    #game-container, .legend-box, #matrix-container, #live-leaderboard {
        max-width: 95vw !important;
        overflow-x: auto; /* Permette lo swipe laterale se lo schermo è molto piccolo */
    }
    #symbols-legend.legend-grid {
        justify-content: flex-start; /* Riporta a sinistra per lo scorrimento */
        gap: 8px;
    }
}

/* --- STILI PODIO FINALE --- */
.podium-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

/* Speciale 1° Posto (Oro) */
.stat-item.rank-1 {
    background: rgba(255, 215, 0, 0.1) !important;
    border-color: #ffd700 !important;
    box-shadow: inset 0 0 15px rgba(255, 215, 0, 0.05);
}

.stat-item.rank-1 .player-name, 
.stat-item.rank-1 .player-score {
    color: #ffd700 !important;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

/* Speciale 2° Posto (Argento) */
.stat-item.rank-2 {
    background: rgba(192, 192, 192, 0.1) !important;
    border-color: #c0c0c0 !important;
}

.stat-item.rank-2 .player-name, 
.stat-item.rank-2 .player-score {
    color: #c0c0c0 !important;
}

/* --- INGRANDIMENTO TESTI CONSOLE LIVE MASTER --- */
.master-table-row {
    font-size: 1.1rem; /* Aumenta la base di tutto il testo */
    padding: 12px 15px; /* Rende la riga più alta e ariosa */
}

/* Ingrandisce il Nome del Giocatore */
.master-table-row div:nth-child(2) {
    font-size: 1.25rem !important;
    font-weight: 700;
}

/* Ingrandisce i Punti */
.mtr-score {
    font-size: 1.3rem !important;
    font-weight: 800;
    color: var(--accent);
}