/* Base & Reset */
body,
html {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    overflow: hidden;
    background: #1a252f;
    color: white;
    user-select: none;
}

/* Header & Topbar */
#topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
    background: #2c3e50;
    padding: 0 20px;
    border-bottom: 2px solid #34495e;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    position: relative;
    z-index: 100;
    transition: background-color 0.3s ease, color 0.3s ease;
}

#topbar,
#user-greeting,
#user-icon,
#user-greeting b {
    color: #ffffff !important;
    text-shadow: 0px 1px 3px rgba(0, 0, 0, 0.9), 0px 0px 8px rgba(0, 0, 0, 0.6) !important;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

#user-greeting {
    font-size: 1.1em;
    letter-spacing: 0.5px;
}

.topbar-actions {
    display: flex;
    gap: 10px;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 34px;
    padding: 0 12px;
    font-size: 0.85em;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    cursor: pointer;
    background: #34495e;
    color: inherit;
    box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.4);
    transition: background 0.2s;
}

.action-btn:hover {
    background: #2980b9;
    color: white;
}

/* App Core Geometry */
.app-container {
    position: relative;
    height: calc(100vh - 60px);
    width: 100vw;
    overflow: hidden;
}

.radial-slice {
    cursor: pointer;
    transition: filter 0.1s;
}

.radial-slice:active {
    filter: brightness(1.2);
}

/* COMPATTA I BLOCCHI CONTATORE */
.counter-display {
    position: absolute;
    transform: translate(-50%, -50%);
    width: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0px;
    /* Ridotto da 8px a 0 per evitare invasioni */
    pointer-events: none;
}

.counter-number {
    font-size: 5rem;
    font-weight: bold;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.5);
    line-height: 1;
    margin: -5px 0;
    /* Avvicina il numerone all'icona e al totale */
}

.root-footer-btn {
    position: fixed;
    bottom: 55px;
    left: 15px;
    z-index: 99;
    background: #c0392b;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 0.8em;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    transition: background 0.2s;
}

.root-footer-btn:hover {
    background: #e74c3c;
}

.counter-label {
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 10px;
    border-radius: 6px;
    white-space: nowrap;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.icon-feedback {
    font-size: 4rem;
    margin-bottom: 0;
    transition: transform 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.icon-feedback.pop {
    transform: scale(1.5);
}

.counter-total {
    font-size: 1.1rem;
    opacity: 0.7;
    font-weight: 500;
    text-transform: lowercase;
}

/* Animations */
.flying-anim {
    position: absolute;
    top: 50%;
    left: -200px;
    transform: translateY(-50%);
    height: 100px;
    opacity: 0;
    pointer-events: none;
    z-index: 5;
}

.fly-active {
    animation: flyAcross 2s linear forwards;
}

@keyframes flyAcross {
    0% {
        left: -200px;
        opacity: 1;
    }

    100% {
        left: 100vw;
        opacity: 1;
    }
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal-content {
    background: #2c3e50;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    text-align: center;
    width: 90%;
    max-width: 320px;
}

.modal-content input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px;
    margin: 8px 0;
    border: 1px solid #34495e;
    border-radius: 4px;
    background: #1a252f;
    color: white;
}

.modal-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    gap: 10px;
}

.modal-buttons .action-btn {
    flex: 1;
    height: 40px;
    font-size: 1em;
}

.auth-tabs {
    display: flex;
    margin-bottom: 15px;
    border-bottom: 2px solid #34495e;
}

.auth-tabs button {
    flex: 1;
    background: none;
    border: none;
    color: #7f8c8d;
    padding: 10px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1em;
    transition: 0.2s;
}

.auth-tabs button.active {
    color: white;
    border-bottom: 2px solid #3498db;
    margin-bottom: -2px;
}

.icon-option {
    font-size: 1.8em;
    padding: 5px;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 8px;
    transition: 0.2s;
}

.icon-option:hover {
    background: rgba(255, 255, 255, 0.1);
}

.icon-option.selected {
    border-color: #3498db;
    background: rgba(52, 152, 219, 0.2);
    transform: scale(1.1);
}

/* Privacy Footer Btn */
.privacy-footer-btn {
    position: fixed;
    bottom: 15px;
    right: 15px;
    z-index: 99;
    background: #34495e;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 0.8em;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* Cookie Banner */
#cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #1a252f;
    color: #ecf0f1;
    padding: 15px 20px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10000;
    box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.5);
    font-size: 0.9em;
    border-top: 2px solid #3498db;
}

#cookie-banner p {
    margin: 0;
    flex: 1;
    padding-right: 20px;
    line-height: 1.4;
}

#cookie-banner a {
    color: #3498db;
    text-decoration: none;
    font-weight: bold;
}

/* 1. TABLET E SCHERMI MEDI */
@media (max-width: 1024px) {
    .counter-display {
        width: 180px;
    }

    .icon-feedback {
        font-size: 3.5rem;
    }

    .counter-number {
        font-size: 4.5rem;
        margin: -5px 0;
    }

    .counter-total {
        font-size: 1.1rem;
    }
}

/* MOBILE GRANDE */
@media (max-width: 768px) {
    #radial-container {
        width: 100vw;
        max-width: 100%;
        margin: 0 auto;
    }

    .counter-display {
        width: 150px;
    }

    .icon-feedback {
        font-size: 3rem;
    }

    .counter-number {
        font-size: 4.5rem;
        margin: -5px 0;
    }

    .counter-total {
        font-size: 1rem;
    }

    .counter-label {
        font-size: 0.95rem;
    }
}

/* MOBILE PICCOLO*/
@media (max-width: 480px) {
    .counter-display {
        width: 120px;
    }

    .icon-feedback {
        font-size: 2.8rem;
    }

    .counter-number {
        font-size: 4rem;
        margin: -5px 0;
    }

    .counter-total {
        font-size: 0.9rem;
    }

    .counter-label {
        font-size: 0.85rem;
        padding: 2px 8px;
    }

    #topbar {
        padding: 0 10px;
    }

    #user-greeting {
        font-size: 0.95em;
    }

    .action-btn {
        font-size: 0.75em;
        padding: 0 8px;
    }
}

@media (max-width: 600px) {
    #cookie-banner {
        flex-direction: column;
        text-align: center;
        gap: 15px;
        padding: 20px;
    }

    #cookie-banner p {
        padding-right: 0;
    }

    #cookie-banner button {
        width: 100%;
    }
}

.btn-share-purple {
    background: #8e44ad !important;
}

.btn-share-purple:hover {
    background: #9b59b6 !important;
}

/* ==========================================================================
   MAPPA DELL'INFERNO (Leaderboard Visiva)
   ========================================================================== */
.map-pin {
    position: absolute;
    transform: translate(-50%, -100%);
    /* Il punto di ancoraggio è alla base dell'icona */
    font-size: 2rem;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 10;
    filter: drop-shadow(0px 3px 5px rgba(0, 0, 0, 0.9));
}

.map-pin.is-me {
    font-size: 2.5rem;
    z-index: 15;
    filter: drop-shadow(0px 0px 10px rgba(241, 196, 15, 0.8));
    /* Alone dorato per te stesso */
}

.map-pin:hover {
    transform: translate(-50%, -100%) scale(1.4);
    z-index: 20;
}

.map-tooltip {
    visibility: hidden;
    position: absolute;
    bottom: 110%;
    /* Appare sopra l'icona */
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    white-space: nowrap;
    font-size: 0.9rem;
    font-family: monospace;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.map-pin:hover .map-tooltip {
    visibility: visible;
    opacity: 1;
}

/* --- UI Password Field & Toggle --- */
.password-container {
    position: relative;
    width: 100%;
}

.toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    user-select: none;
    font-size: 1.1em;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.toggle-password:hover {
    opacity: 1;
}

/* --- Feedback Requisiti --- */
.password-criteria {
    text-align: left;
    font-size: 0.8em;
    list-style-type: none;
    padding-left: 0;
    margin-top: 5px;
    margin-bottom: 15px;
}

.password-criteria li {
    margin-bottom: 3px;
    transition: color 0.3s;
}

.crit-ko {
    color: #e74c3c;
}

.crit-ko::before {
    content: '❌ ';
}

.crit-ok {
    color: #27ae60;
}

.crit-ok::before {
    content: '✅ ';
}

.map-footer-btn {
    position: fixed;
    bottom: 15px;
    left: 15px;
    z-index: 99;
    background: #c0392b;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 0.8em;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    transition: background 0.2s;
}

.map-footer-btn:hover {
    background: #e74c3c;
}

/* --- Utility Classes --- */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.w-100 {
    width: 100%;
}

/* --- Pulsanti Colorati --- */
.btn-blue {
    background: #2980b9 !important;
}

.btn-green {
    background: #27ae60 !important;
}

.btn-red {
    background: #c0392b !important;
}

.btn-gray {
    background: #7f8c8d !important;
}

.btn-purple {
    background: #8e44ad !important;
}

.btn-dark {
    background: rgba(0, 0, 0, 0.2) !important;
}

/* --- Topbar & Hamburger --- */
.hamburger-btn {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    font-size: 1.5em;
    padding: 0 5px !important;
}

/* --- Blocchi Statistiche & Card --- */
.stats-total-box {
    background: linear-gradient(135deg, #2c3e50, #1a252f);
    padding: 20px;
    border-radius: 12px;
    border: 2px solid #3498db;
    margin-bottom: 25px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.stats-total-label {
    display: block;
    font-size: 0.85em;
    color: #3498db;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: bold;
    margin-bottom: 5px;
}

.stats-total-number {
    font-size: 3.5em;
    font-weight: bold;
    color: #fff;
    line-height: 1;
}

.stats-girone-info {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.share-card-prompt {
    background: #1a252f;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #34495e;
    margin-bottom: 15px;
}

/* --- Tabelle Root & Stats --- */
.root-table-container {
    max-height: 300px;
    overflow-y: auto;
    background: #1a252f;
    border-radius: 4px;
    padding: 10px;
}

.root-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9em;
}

.root-table th,
.root-table td {
    padding: 8px;
}

.root-table tr {
    border-bottom: 1px solid #34495e;
}

#notification-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10001;
    /* Sopra modali e topbar */
    pointer-events: none;
    /* Non blocca i click sui quadranti se non ci sono toast */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

/* --- Stili per il Toast di Annullamento --- */
.toast-content-undo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.btn-undo {
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 10px;
    cursor: pointer;
    margin-left: 15px;
    font-weight: bold;
    transition: background 0.2s;
}

.btn-undo:hover {
    background: #c0392b;
}

.btn-undo:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

/* --- Modale Statistiche Scorrevole --- */
.stats-modal-large {
    max-width: 500px;
    max-height: 90vh; /* Non supera il 90% dell'altezza dello schermo */
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Evita che il contenuto sbordi dalla modale */
    padding-bottom: 15px;
}

.stats-scroll-area {
    overflow-y: auto; /* Attiva lo scroll verticale */
    flex: 1; /* Occupa tutto lo spazio disponibile */
    margin: 15px 0;
    padding-right: 10px; /* Lascia spazio per la barra di scorrimento */
}

/* Stile opzionale per rendere la barra di scorrimento più elegante (solo per Webkit) */
.stats-scroll-area::-webkit-scrollbar {
    width: 6px;
}
.stats-scroll-area::-webkit-scrollbar-thumb {
    background: #34495e;
    border-radius: 4px;
}