* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body,
html {
    width: 100%;
    height: 100%;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background-color: #000;
    /* Fallback */
    background-image: url('../assets/bg/community_background.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    overflow: hidden;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* --- Login Overlay --- */
#login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: all 0.5s ease;
    padding-top: 20%;
}

.login-box h2 {
    margin-top: 0;
    color: #ffffff;
}

/* Formulaire injecté dans le Hero Stack */
#hero-login-form {
    position: absolute;
    top: 70%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0px;
    z-index: 50;
    width: 300px;
    pointer-events: auto;
}

#pseudo-input,
#password-input {
    padding: 12px 20px;
    font-size: 18px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border-radius: 30px;
    margin-bottom: 10px;
    /* Increased slightly for spacing */
    width: 250px;
    text-align: center;
    outline: none;
    transition: all 0.3s;
}

#pseudo-input:focus,
#password-input:focus {
    border-color: #fff;
    background: rgba(0, 0, 0, 0.7);
}

.form-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

button {
    padding: 10px 25px;
    font-size: 16px;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    transition: background 0.3s, transform 0.2s;
    font-weight: bold;
    color: white;
}

.btn-primary {
    background-color: #007bff;
}

.btn-primary:hover {
    background-color: #0056b3;
}

.btn-secondary {
    background-color: #6c757d;
}

.btn-secondary:hover {
    background-color: #545b62;
}

/* --- Main Content --- */
.hidden {
    display: none !important;
}

#main-content {
    padding: 2rem;
    text-align: center;
    color: #333;
    /* IMPORTANT: Allow clicks to pass through to the 3D Canvas */
    pointer-events: none;
    position: absolute;
    /* Find-safe: Ensure it overlays correctly if needed */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    /* Above canvas, below modals */
}

/* Re-enable pointer events for interactive children */
#main-content>* {
    pointer-events: auto;
}

/* --- Labels Container --- */
#labels-container {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: auto;
    min-height: 60px;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: center;
    padding: 10px;
    box-sizing: border-box;
    gap: 10px;
    z-index: 9000 !important;
    /* High but below overlays */
    pointer-events: none;
}

/* --- Etiquette Style --- */
.user-label {
    pointer-events: auto;
    background-color: #28a745;
    color: white;
    padding: 6px 6px 6px 4px;
    border-radius: 9px;
    font-weight: bold;
    font-size: 14px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    border: 2px solid transparent;
    user-select: none;
    text-transform: capitalize;
}

.user-label.pop-in {
    animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.user-label.current-user {
    background-color: #1e7e34;
    border: 2px solid #ffc107;
    box-shadow: 0 0 10px rgba(255, 193, 7, 0.5);
    z-index: 10;
}

.user-label::before {
    content: "👤";
    margin-right: 5px;
    background-color: #28a745;
    color: white;
    padding: 2px 2px;
    border-radius: 50%;
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

#main-content {
    color: white;
}

.toast-connection-lost {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #ff9800;
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    font-weight: bold;
    font-size: 16px;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        top: -50px;
        opacity: 0;
    }

    to {
        top: 20px;
        opacity: 1;
    }
}

/* --- 3D POPUP (Glassmorphism) --- */
.popup-3d {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 255, 255, 0.3);
    border-radius: 15px;
    color: white;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.2);
    z-index: 11000 !important;
    /* Above Labels (9000) */
    text-align: center;
    animation: popupFadeIn 0.3s ease-out;
}

.popup-3d h3 {
    margin-top: 0;
    color: #00ffff;
    font-size: 1.5rem;
    margin-bottom: 10px;
    text-shadow: 0 0 5px rgba(0, 255, 255, 0.5);
}

.popup-3d p {
    font-size: 1rem;
    line-height: 1.5;
    color: #ddd;
}

.popup-3d .close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    cursor: pointer;
    font-weight: bold;
    color: #aaa;
    font-size: 1.2rem;
    transition: color 0.2s;
}

.popup-3d .close-btn:hover {
    color: white;
}

@keyframes popupFadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -60%);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

/* --- GENERIC MODAL MANAGER --- */
#global-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 10000;
    /* Standardized Modal Z-Index */
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#global-modal-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.modal-box {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 1px solid #4ecca3;
    border-radius: 12px;
    box-shadow: 0 0 20px rgba(78, 204, 163, 0.3);
    color: #fff;
    min-width: 300px;
    max-width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.modal-header {
    padding: 15px 20px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(78, 204, 163, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: #4ecca3;
}

.modal-close-btn {
    cursor: pointer;
    font-size: 1.5rem;
    color: #aaa;
    transition: color 0.2s;
}

.modal-close-btn:hover {
    color: #fff;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* --- Growing Modal Animation --- */
.modal-grow {
    animation: modalGrow 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-origin: center;
}

@keyframes modalGrow {
    from {
        transform: scale(0);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}