
:root {
    --main-color: #e74c3c;
    --glass-bg: rgba(0, 0, 0, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-color: #ffffff;
    --char-text-color: #ffffff;
    --char-highlight-color: #e74c3c;
    --char-border-color: #3498db;
}

/* Thèmes */
.theme-bleu-dark { --main-color: #1f618d; } /* dark blue */
.theme-bleu-medium { --main-color: #0042ad; } /* medium blue */
.theme-bleu-light { --main-color: #00a2ff; } /* light blue */
.theme-rouge { --main-color: #ff1900; }
.theme-vert-dark { --main-color: #1e8449; } /* dark green */
.theme-vert-medium { --main-color: #00b344; } /* medium green */
.theme-vert-light { --main-color: #00ff55; } /* light green */
.theme-violet { --main-color: #8f00b3; }
.theme-orange { --main-color: #ff7700; }
.theme-rose { --main-color: #ff00f2; }

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #000;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    position: relative;
    box-sizing: border-box;
}

#phone-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

#game {
    display: block;
    width: 100%;
    height: 100%;
    position: absolute;
    z-index: 1;
}

#menu-principal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000000 !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start; /* Collé en haut */
    padding-top: 25px;
    padding-bottom: 25px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
    z-index: 3;
}

#menu-contenu {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Flex item de #menu-principal : sans ce garde-fou, flex-shrink:1
       l'écrase quand le contenu dépasse la hauteur visible — le cadre
       s'arrêtait alors avant les derniers boutons (Déconnexion, pub). */
    flex-shrink: 0;
    width: 90%;
    max-width: 340px;
    padding: 20px;
    background: #000000 !important;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5), 0 0 20px var(--main-color);
    box-sizing: border-box;
}

#menu-contenu h1 {
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0 0 20px 0;
    font-size: 1.3rem;
    color: var(--main-color);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 0 0 10px var(--main-color);
}

/* Grille de boutons compacte et centrée */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    width: 100%;
    margin-top: 10px;
}

button {
    background: var(--main-color);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    box-sizing: border-box;
}

/* Style for the square logout button */
.btn-logout-square {
    width: 40px;
    height: 40px;
    padding: 0;
    margin-left: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--main-color);
    border: 2px solid var(--main-color);
    border-radius: 8px;
    font-size: 1.2rem;
    cursor: pointer;
}

.btn-logout-square:hover {
    background: var(--main-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 0 15px var(--main-color);
}

#dynamic-menu-container {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    align-items: start;
    box-sizing: border-box;
}

.menu-item {
    width: 100%;
}

#dynamic-menu-container > .menu-item.has-submenu {
    grid-column: 1 / -1;
}

.menu-hint {
    grid-column: 1 / -1;
    margin: 2px 0 10px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px dashed var(--main-color);
    color: rgba(255, 255, 255, 0.92);
    font-size: 0.82rem;
    line-height: 1.45;
    text-align: center;
    background: rgba(255, 255, 255, 0.05);
}

.menu-hint strong {
    color: var(--main-color);
}

.real-life-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.real-life-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.real-life-form label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.8rem;
}

.real-life-form textarea,
.real-life-form input {
    box-sizing: border-box;
    width: 100%;
    padding: 8px;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.real-life-result {
    margin-top: 10px;
    padding: 10px;
    border-left: 3px solid var(--main-color);
    background: rgba(255, 255, 255, 0.05);
    font-size: 0.85rem;
}

.real-life-result small {
    display: block;
    margin-top: 4px;
    opacity: 0.65;
}

.real-life-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-top: 12px;
}

.real-life-tabs button {
    padding: 8px 6px;
    font-size: 0.8rem;
    background: rgba(255, 255, 255, 0.08);
}

.real-life-tabs button.active {
    background: var(--main-color);
}

.imc-meter-container {
    margin-top: 14px;
    padding: 10px 0;
}

.imc-slider {
    width: 100%;
    height: 18px;
    border-radius: 999px;
    background: linear-gradient(to right, #3498db 0 14%, #2ecc71 14% 40%, #f1c40f 40% 60%, #e67e22 60% 80%, #e74c3c 80% 100%);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.imc-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    border: 2px solid var(--main-color);
}

.imc-slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    border: 2px solid var(--main-color);
}

.imc-slider:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.imc-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.6);
}

.real-life-post {
    padding: 10px 0;
    border-bottom: 1px solid var(--glass-border);
}

.real-life-post time {
    margin-left: 8px;
    font-size: 0.72rem;
    opacity: 0.6;
}

.real-life-post p {
    margin: 6px 0 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

@media (max-width: 560px) {
    .real-life-grid {
        grid-template-columns: 1fr;
    }
}

.menu-button {
    width: 100%;
    max-width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    text-align: center;
    min-height: 52px;
    box-sizing: border-box;
    overflow-wrap: anywhere;
}

/* Garde-fous : aucun bouton ne doit dépasser son cadre, même avec
   un libellé long ou un padding exagéré. */
#menu-contenu button,
#menu-contenu .menu-button,
#dynamic-menu-container button,
#dynamic-menu-container .menu-button,
#dynamique-contenu-detail button,
.rpg-card button {
    max-width: 100%;
    box-sizing: border-box;
}

.menu-item {
    min-width: 0;
}

.submenu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
    margin-left: 12px;
    padding-left: 10px;
    border-left: 1px solid rgba(255, 255, 255, 0.12);
}

.submenu .menu-button {
    text-align: left;
}

/* Menu Commerce : boutons alignés deux par ligne (paires voulu). */
.submenu-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

@media (max-width: 560px) {
    .submenu-2col {
        grid-template-columns: 1fr 1fr;
    }
}

#themes-section {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    width: 100%;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    padding: 4px 6px 6px 2px;
    margin-bottom: 12px;
    box-sizing: border-box;
}

#themes-section::-webkit-scrollbar {
    width: 6px;
}
#themes-section::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}
#themes-section::-webkit-scrollbar-thumb {
    background: var(--main-color);
    border-radius: 10px;
}

#themes-section .theme-button {
    width: 100%;
    min-height: 48px;
    padding: 10px 8px;
    margin-bottom: 0;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.9rem;
    border: 2px solid rgba(255, 255, 255, 0.25);
    background-color: var(--theme-btn-bg, var(--main-color));
    border-color: var(--theme-btn-bg, var(--main-color));
    color: var(--theme-btn-text, #ffffff);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    box-sizing: border-box;
    transition: transform 0.15s ease, filter 0.15s ease, border-color 0.15s ease;
}

#themes-section .theme-button:hover,
#themes-section .theme-button:focus-visible {
    filter: brightness(1.15);
    transform: scale(1.02);
}

button:hover {
    filter: brightness(1.2);
    transform: translateY(-2px);
    box-shadow: 0 0 15px var(--main-color);
}

#btn-lancer-jeu {
    width: 100%;
    padding: 15px;
    margin-bottom: 5px;
    font-size: 1.1rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3), 0 0 15px var(--main-color);
}

/* Tech badges styling */
.status-box {
    position: fixed;
    left: 1rem;
    bottom: 50px;
    display: flex;
    align-items: center;
    gap: 0.1rem;
    padding: 0.3rem 0.6rem;
    background: rgba(0,0,0,0.6);
    border: 1px solid #000000;
    border-radius: 0.5rem;
    z-index: 10000;
}
.status-box .label {
    color: #fff;
    font-size: 0.8rem;
    margin-right: 0.3rem;
}
.status-box .state {
    color: #0f0; /* green for active */
    font-weight: bold;
    font-size: 0.8rem;
    margin-left: 0;
    margin-right: 0.2rem;
}
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    font-size: 0.8rem;
    margin-right: 0;
    border: 1px solid #000000; /* black border */
}

/* Specific badge shapes */
.badge-php {
    background: #8A2BE2; /* violet */
    color: #000000; /* black */
    border-radius: 3rem; /* more oval */
}

.badge-deno {
    background: #28a745; /* green */
    color: #000000; /* black text */
    border-radius: 0; /* rectangular */
}

.badge-python.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    font-size: 0.8rem;
    margin-right: 0;
    border: 1px solid #000000; /* black border */
}

/* Specific badge shapes */
.badge-php {
    background: #8A2BE2; /* violet */
    color: #000000; /* black */
    border-radius: 1.5rem; /* more oval */
}

.badge-deno {
    background: #28a745; /* green */
    color: #000000; /* black text */
    border: 1px solid #ffffff; /* white border */
    border-radius: 0; /* rectangular */
}

.badge-python {
    background: #306998; /* python blue */
    color: #FFFF00; /* yellow text */
    border: 1px solid #ffffff; /* white border */
    border-radius: 0.5rem;
}

/* CSS for credits list - 2 per line */
.credits-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px; /* Adjust as needed for spacing between cards */
    width: 100%;
    margin-top: 10px;
}

.credits-grid .credit-card {
    width: auto ; /* Override inline 100% width */
    margin: 0; /* Remove vertical margin, grid gap handles spacing */
    height: 100%; /* Ensure cards fill grid cell height */
    display: flex; /* Re-enable flex for internal alignment if desired */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

/* duplicate badge styles removed */
#ecran-parametres, #ecran-todo, #ecran-credits, #ecran-scenario {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000000 !important;
    z-index: 8;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    box-sizing: border-box;
    overflow: hidden;
}

#parametres-contenu, #credits-contenu-detail, #todo-contenu-detail, #scenario-contenu {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 90%;
    max-width: 440px;
    height: 85vh;
    max-height: calc(100% - 24px);
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 25px;
    padding: 12px 14px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5), 0 0 20px var(--main-color);
    box-sizing: border-box;
    overflow: hidden;
    position: relative;
}

#parametres-titre, #credits-titre {
    margin: 0 0 15px 0;
    font-size: 1.3rem;
    color: var(--main-color);
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 0 0 10px var(--main-color);
    text-align: center;
    flex-shrink: 0;
}

#credits-liste, .dynamic-container {
    width: 100%;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    margin-bottom: 12px;
    padding-right: 5px;
    box-sizing: border-box;
}

#credits-liste::-webkit-scrollbar,
.dynamic-container::-webkit-scrollbar {
    width: 6px;
}
#credits-liste::-webkit-scrollbar-track,
.dynamic-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}
#credits-liste::-webkit-scrollbar-thumb,
.dynamic-container::-webkit-scrollbar-thumb {
    background: var(--main-color);
    border-radius: 10px;
}

.btn-retour {
    width: 100%;
    max-width: 220px;
    padding: 12px 20px;
    margin-top: 4px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 12px;
    color: #ffffff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: background 0.2s, transform 0.15s;
}

.btn-retour:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: translateY(-2px);
}

#scenario-details {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: calc(85vh - 120px);
    overflow-y: auto;
}

/* Overlay de l'authentification */
#formulaire-auth {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 8;
}

#auth-contenu {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 25px;
    border-radius: 20px;
    width: 85%;
    max-width: 320px;
    border: 1px solid var(--glass-border);
    color: white;
    box-shadow: 0 15px 35px rgba(0,0,0,0.5);
    text-align: center;
    max-height: calc(100% - 24px);
    overflow-y: auto;
    box-sizing: border-box;
}

.form-group {
    margin-bottom: 15px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.85rem;
    color: white;
}

.form-group input {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    box-sizing: border-box;
}

.city-building-card--locked {
    opacity: 0.45;
    filter: grayscale(1);
    cursor: not-allowed;
}

.city-building-card--locked small {
    color: rgba(255, 255, 255, 0.65);
}

.housing-move-form .housing-field {
    background: #20252f !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-sizing: border-box;
}

.housing-move-form .housing-field option {
    background: #20252f;
    color: #ffffff;
}

#auth-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 15px;
    padding: 15px;
    background: rgba(0,0,0,0.2);
    border-radius: 15px;
}

.auth-btn {
    width: 100%;
    background: var(--main-color);
    opacity: 0.9;
}

.auth-separator {
    text-align: center;
    font-size: 0.7rem;
    color: rgba(255,255,255,0.3);
    margin: 5px 0;
}

.cache { display: none !important; }

#hud-jeu {
    position: absolute;
    inset: 0;
    z-index: 4;
    pointer-events: none;
}
#hud-jeu > * { pointer-events: auto; }
#btn-quitter-jeu {
    position: absolute;
    /* Bas-gauche, au-dessus du toggle chat : le haut de l'écran est
       couvert par la bannière pub in-page push. */
    bottom: calc(160px + env(safe-area-inset-bottom));
    left: 12px;
}
/* HUD vitalité (ABI v4) : PV du joueur local, indicateur arme, overlay KO.
   Purement informatif → pas d'interaction. */
#hud-vie,
#hud-ko { pointer-events: none; }
#hud-vie {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: rgba(10, 12, 16, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    color: #fff;
    font-size: 0.85rem;
}
#hud-vie-barre {
    width: 120px;
    height: 10px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 5px;
    overflow: hidden;
}
#hud-vie-remplissage {
    height: 100%;
    width: 100%;
    background: #39d05a;
    border-radius: 5px;
    transition: width 0.15s ease-out;
}
#hud-vie-texte { min-width: 64px; text-align: center; }
#hud-arme,
#hud-etat {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
}
#hud-arme {
    background: rgba(255, 190, 60, 0.18);
    border: 1px solid rgba(255, 190, 60, 0.55);
}
/* État joueur (etat_joueur proto v2) : réanimation / urgence. Textes
   placeholder en attendant la spec serveur. */
#hud-etat {
    background: rgba(80, 140, 255, 0.18);
    border: 1px solid rgba(120, 170, 255, 0.55);
}
/* Horloge du monde (heure_monde, rendu/horloge.js) : discrète, haut-centre. */
#hud-horloge {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 12px;
    background: rgba(10, 12, 16, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    color: #fff;
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
    pointer-events: none;
    white-space: nowrap;
}
/* Badge météo (rendu/meteo.js) : même style que l'horloge, juste en
   dessous (haut-centre du HUD). */
#hud-meteo {
    position: absolute;
    top: 46px;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 10px;
    background: rgba(10, 12, 16, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    color: #fff;
    font-size: 0.75rem;
    pointer-events: none;
    white-space: nowrap;
}
#hud-ko {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(120, 10, 10, 0.28);
    color: #fff;
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
}
#pad-gauche {
    display: none;
    position: absolute;
    left: 24px;
    bottom: 28px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.2);
    touch-action: none;
}
#pad-stick {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 46px;
    height: 46px;
    margin: -23px 0 0 -23px;
    border-radius: 50%;
    background: var(--main-color);
    opacity: 0.85;
}
#pad-droite {
    display: none;
    position: absolute;
    right: 18px;
    bottom: 28px;
    gap: 10px;
}
#pad-droite button {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: var(--main-color);
    color: var(--theme-text-color, #fff);
    font-weight: 700;
}
/* Réticle de visée TPS : petite pastille centrale discrète (la vraie
   visée est le yaw `aim_yaw` envoyé au serveur — voir rendu/visee.js). */
#visee-reticle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 6px;
    height: 6px;
    margin: -3px 0 0 -3px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
    pointer-events: none;
}
/* Badge erreurs réseau (`fusion:erreur-reseau`) : coin haut-centre,
   auto-masqué par jeu.js après 4 s. */
#badge-erreur-reseau {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 12px;
    border-radius: 10px;
    background: rgba(140, 20, 20, 0.75);
    border: 1px solid rgba(255, 120, 120, 0.6);
    color: #fff;
    font-size: 0.78rem;
    pointer-events: none;
    white-space: nowrap;
}
#aide-pc {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.55);
    font-size: 0.8rem;
    pointer-events: none;
}
body.jeu-tactile #pad-gauche,
body.jeu-tactile #pad-droite { display: block; }
body.jeu-tactile #pad-droite { display: flex; flex-direction: column; }
body.jeu-tactile #aide-pc { display: none; }
body.en-jeu #chat-toggle-btn,
body.en-jeu #inventaire-toggle-btn,
body.en-jeu #notifications-toggle-btn,
body.en-jeu #inventaire-panel,
body.en-jeu #notifications-panel,
/* Les pages dynamiques (stats membres, personnage, commerce…) ne
   doivent JAMAIS recouvrir le jeu — même si un affichage tardif
   tente de les montrer (race au lancement de scène). */
body.en-jeu #ecran-dynamique,
body.en-jeu .status-box,
body.en-jeu .monetag-mobile-banner,
body.en-jeu .monetag-desktop-rail { display: none !important; }

/* Invité (non connecté) : pas de boutons ronds fixes en bas d'écran
   (chat / inventaire / notifications). La classe `utilisateur-invite`
   est posée sur <body> par wasm_loader.js (renderUserBanner). */
body.utilisateur-invite #chat-toggle-btn,
body.utilisateur-invite #inventaire-toggle-btn,
body.utilisateur-invite #notifications-toggle-btn { display: none !important; }

#ui-debug {
    position: absolute;
    bottom: 10px;
    right: 10px;
    color: #00ff00;
    font-family: monospace;
    z-index: 2;
    pointer-events: none;
}

#mobile-warning {
    position: fixed;
    top: 10px;
    left: 10px;
    border-radius: 0 5px 5px 0;
    font-size: 13px;
    z-index: 9;
    display: none;
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 10px;
}

@media (min-width: 768px) {
    #mobile-warning { display: block; }
}

/* Theme-aware button styling */
.menu-button.theme-color {
    background: var(--main-color);
    color: var(--theme-text-color);
    border-color: var(--main-color);
}

/* Thème sélectionné */
.theme-button.active::after {
    content: ' ✓';
    margin-left: 6px;
}

.theme-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 4px;
    background: rgba(255,255,255,0.2);
    color: #fff;
    border-radius: 4px;
    font-size: 0.75rem;
}

/* Écran Dynamique */
#ecran-dynamique {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000000 !important;
    z-index: 8;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
}

#dynamique-contenu-detail {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 94%;
    max-width: 920px;
    height: 88vh;
    overflow-x: hidden;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 25px;
    padding: 12px 14px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5), 0 0 20px var(--main-color);
    box-sizing: border-box;
}

#dynamique-titre {
    margin: 0 0 15px 0;
    font-size: 1.4rem;
    color: var(--main-color);
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 0 0 10px var(--main-color);
    text-align: center;
}

#dynamique-corpus {
    width: 100%;
    flex: 1;
    overflow-y: auto;
    margin-bottom: 15px;
    padding-right: 5px;
}

#dynamique-corpus::-webkit-scrollbar {
    width: 6px;
}
#dynamique-corpus::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}
#dynamique-corpus::-webkit-scrollbar-thumb {
    background: var(--main-color);
    border-radius: 10px;
}

/* RPG Stats & Progress bars */
.rpg-sheet {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.rpg-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 12px 15px;
    margin-bottom: 10px;
    transition: all 0.2s ease;
}

.rpg-card:hover {
    border-color: var(--main-color);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.05);
}

.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.quick-actions-grid button {
    min-height: 40px;
    padding: 8px 4px;
    font-size: 0.78rem;
    line-height: 1.2;
    white-space: normal;
    overflow-wrap: anywhere;
}

.stat-row {
    margin-bottom: 10px;
}

.stat-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    font-weight: bold;
    margin-bottom: 4px;
}

.stat-bar-container {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 5px;
    overflow: hidden;
}

.stat-bar {
    height: 100%;
    border-radius: 5px;
    transition: width 0.3s ease;
}

.stat-bar.health { background: linear-gradient(90deg, #ff3b30, #ff9500); }
.stat-bar.energy { background: linear-gradient(90deg, #007aff, #34c759); }
.stat-bar.physique { background: linear-gradient(90deg, #af52de, #ff2d55); }
.stat-bar.mentale { background: linear-gradient(90deg, #5856d6, #00c7be); }
.stat-bar.magique { background: linear-gradient(90deg, #ffcc00, #ff9500); }

/* Tabs Header */
.tabs-header {
    display: flex;
    width: 100%;
    gap: 5px;
    margin-bottom: 15px;
    background: rgba(255, 255, 255, 0.05);
    padding: 3px;
    border-radius: 10px;
}

.tab-btn {
    flex: 1;
    padding: 8px 5px;
    font-size: 0.78rem;
    background: transparent;
    border-radius: 8px;
    transition: all 0.2s ease;
    border: none;
    font-weight: bold;
    cursor: pointer;
}

.tab-btn.active {
    background: var(--main-color);
    color: white;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.tab-content {
    width: 100%;
}

/* Grille d'inventaire */
.inventory-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.inventory-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 10px 15px;
    transition: all 0.2s ease;
}

.inventory-item:hover {
    border-color: var(--main-color);
}

.item-info {
    display: flex;
    flex-direction: column;
}

.item-name {
    font-weight: bold;
    font-size: 0.88rem;
}

.item-qty {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
}

.btn-transfer {
    font-size: 0.72rem;
    padding: 5px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.12);
}

.btn-transfer:hover {
    background: var(--main-color);
    box-shadow: 0 0 10px var(--main-color);
}

/* Dialogue/Modal de transfert */
.transfer-dialog {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    margin-top: 15px;
    width: 100%;
    box-sizing: border-box;
}

.transfer-dialog label {
    font-size: 0.8rem;
    font-weight: bold;
}

.transfer-dialog select, .transfer-dialog input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 8px;
    color: white;
    font-weight: bold;
}

/* Social cards */
.no-friends {
    color: #bbbbbb;
    text-align: center;
    padding: 1rem;
    font-size: 0.9rem;
}

.friend-card {
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 12px 15px;
    margin-bottom: 8px;
}

.friend-details {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.friend-name {
    font-weight: bold;
    font-size: 0.9rem;
}

.friend-meta {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
}

.friend-actions {
    display: flex;
    gap: 5px;
}

.btn-action-small {
    font-size: 0.7rem;
    padding: 4px 8px;
    border-radius: 6px;
}

.cooperation-card {
    display: flex;
    gap: 10px;
}

.btn-renfort {
    align-self: center;
    background: var(--main-color);
}

.btn-renfort:disabled {
    cursor: default;
    opacity: 0.55;
    filter: grayscale(0.4);
}

/* ========== CHAT WINDOW STYLES ========== */
#conv-app {
    position: fixed;
    bottom: 90px;
    left: 20px;
    right: auto;
    width: 350px;
    width: min(350px, calc(100vw - 40px));
    max-width: calc(100vw - 40px);
    height: 550px;
    height: min(550px, calc(100vh - 102px));
    height: min(550px, calc(100dvh - 102px));
    max-height: calc(100vh - 102px);
    max-height: calc(100dvh - 102px);
    background: #1a1a1a;
    border: 1px solid var(--main-color);
    border-radius: 15px;
    display: flex;
    flex-direction: row;
    z-index: 50;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.5), 0 0 20px var(--main-color);
    margin: 0;
    overflow: hidden;
    box-sizing: border-box;
}

#liste-amis {
    width: 80px;
    background: rgba(0, 0, 0, 0.5);
    border-right: 1px solid var(--main-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 10px 5px;
}

#amis-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ami-item {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--main-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: white;
    font-weight: bold;
    font-size: 0.8rem;
    text-align: center;
    border: 2px solid transparent;
}

.ami-item:hover {
    border-color: white;
    transform: scale(1.05);
}

#chat-window {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #000000;
    border-radius: 0 15px 0 0;
    overflow: hidden;
}

#chat-header {
    background: var(--main-color);
    color: white;
    padding: 12px 15px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 0 15px 0 0;
}

#chat-header button {
    background: none;
    border: none;
    color: white;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0;
    margin: 0;
}

#messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#messages::-webkit-scrollbar {
    width: 4px;
}
#messages::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}
#messages::-webkit-scrollbar-thumb {
    background: var(--main-color);
    border-radius: 2px;
}

.message {
    padding: 10px 12px;
    border-radius: 10px;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    font-size: 0.9rem;
    max-width: 100%;
}

.message.sent {
    background: var(--main-color);
    color: white;
    margin-left: auto;
    max-width: 80%;
}

.message.received {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    margin-right: auto;
    max-width: 80%;
}

.input-area {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--main-color);
    background: rgba(0, 0, 0, 0.3);
    align-items: center;
}

#input-msg {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--main-color);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
}

#input-msg::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

#emoji-btn {
    cursor: pointer;
    font-size: 1.1rem;
    transition: transform 0.2s;
}

#emoji-btn:hover {
    transform: scale(1.2);
}

.input-area button {
    background: var(--main-color);
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: white;
    font-size: 1rem;
    transition: all 0.2s;
}

.input-area button:hover {
    filter: brightness(1.2);
}

/* Media Overlay */
#media-overlay {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 200px;
    height: 250px;
    background: #000;
    border: 2px solid var(--main-color);
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 51;
    gap: 15px;
}

#appel-info {
    color: white;
    font-weight: bold;
}

#media-img {
    width: 180px;
    height: 180px;
    border-radius: 10px;
    object-fit: cover;
}

.btn-stop {
    background: #ff3b30;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
}

.btn-stop:hover {
    background: #ff5252;
}

/* ========== PLATFORM SELECTOR ========== */
#platform-selector {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

#platform-modal {
    background: #000;
    border: 2px solid var(--main-color);
    border-radius: 20px;
    padding: 40px 30px;
    text-align: center;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8), 0 0 30px var(--main-color);
}

#platform-modal h2 {
    color: var(--main-color);
    margin: 0 0 30px 0;
    font-size: 1.8rem;
    text-shadow: 0 0 10px var(--main-color);
}

#platform-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.platform-btn {
    background: var(--main-color);
    color: white;
    padding: 15px 20px;
    border: 2px solid transparent;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.platform-btn:hover {
    border-color: white;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px var(--main-color);
}

.platform-btn:active {
    transform: translateY(-1px);
}

/* Personnage - couleurs du prénom uniquement (couleurs préférées) */
.char-prenom-text {
    color: var(--char-text-color, #ffffff);
}
.char-prenom-outline {
    -webkit-text-stroke: 1px var(--char-highlight-color, #e74c3c);
    text-stroke: 1px var(--char-highlight-color, #e74c3c);
}
.char-prenom-border {
    border: 2px solid var(--char-border-color, #3498db);
    padding: 2px 6px;
    border-radius: 6px;
    display: inline-block;
}

.char-themed {
    color: var(--main-color);
}

.stats-grid-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

@media (max-width: 520px) {
    .stats-grid-layout {
        grid-template-columns: 1fr;
    }
}

.stats-horizontal .stat-slider-row,
.stats-vertical .stat-slider-row {
    margin-bottom: 8px;
}

.stat-slider-row label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.82rem;
    margin-bottom: 4px;
}

.stat-intelligence .intelligence-range {
    pointer-events: none;
}

.stat-adjust-controls {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
}

.stat-adjust {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    width: 24px;
    height: 24px;
    padding: 0;
    border-radius: 50%;
    background: var(--main-color);
    border: 1px solid var(--main-color);
    color: #fff;
    line-height: 1;
    font-size: 1rem;
}

.stat-val {
    min-width: 24px;
    text-align: center;
}

.stat-range {
    width: 100%;
    height: 20px;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    min-width: 0;
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    accent-color: var(--main-color);
}

.stat-range::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(to right, var(--main-color) 0 var(--range-progress, 0%), rgba(255, 255, 255, 0.22) var(--range-progress, 0%) 100%);
}

.stat-range::-webkit-slider-thumb {
    width: 18px;
    height: 18px;
    margin-top: -6px;
    border: none;
    border-radius: 50%;
    background: var(--main-color);
    cursor: pointer;
    -webkit-appearance: none;
}

.stat-range::-moz-range-track {
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.22);
}

.stat-range::-moz-range-progress {
    height: 6px;
    border-radius: 999px;
    background: var(--main-color);
}

.stat-range::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border: none;
    border-radius: 50%;
    background: var(--main-color);
    cursor: pointer;
}

.stat-hint {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.55);
    margin: 0 0 8px 0;
}

.skill-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.skill-row input[type="range"] {
    width: 100%;
}

.skill-points-summary-top {
    margin-top: 0;
}

.knowledge-section,
.language-section {
    margin-top: 14px;
}

.level-control-line {
    display: flex;
    align-items: center;
    gap: 6px;
}

.level-control-line .stat-range {
    flex: 1 1 0;
    width: 0;
    min-width: 0;
}

.level-control-line .level-adjust {
    flex: 0 0 24px;
}

.level-name-controls {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 6px;
}

.level-value {
    min-width: 18px;
    text-align: center;
}

.level-adjust {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--main-color);
    color: #fff;
    line-height: 1;
    font-size: 1rem;
}

.language-row {
    display: grid;
    grid-template-columns: minmax(90px, 1fr) auto auto minmax(80px, 2fr) auto auto;
    align-items: center;
    gap: 8px;
}

.language-row select {
    min-width: 0;
    width: auto;
}

.language-row .language-range {
    min-width: 80px;
    width: 100%;
}

.language-level {
    min-width: 18px;
    text-align: center;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.identity-preferences-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    align-items: flex-start;
    overflow-x: auto;
}

/* Sur PC les rangées nowrap du formulaire de création débordaient :
   les <select> gardent une largeur intrinsèque (option la plus longue)
   et aucune des rangées identité ne permettait le scroll horizontal. */
.identity-compact,
.identity-4col {
    overflow-x: auto;
    scrollbar-width: thin;
}

.identity-compact select,
.identity-4col select,
.identity-preference-field select {
    min-width: 0;
    max-width: 100%;
}

.identity-preference-field {
    flex: 1 1 0;
    min-width: 0;
}

.identity-preference-field select {
    width: 100%;
    min-width: 0;
}

.form-row .form-group {
    flex: 1;
    min-width: 120px;
}

.identity-compact {
    align-items: flex-end;
}

.form-group-compact {
    flex: 1;
    min-width: 90px;
    max-width: 160px;
}

.form-group-age {
    flex: 0 0 72px;
    max-width: 80px;
}

.form-group-age input[type="number"] {
    width: 100%;
}

.form-group-genre {
    flex: 0 0 108px;
    max-width: 120px;
}

.form-group-morpho {
    flex: 1;
    min-width: 120px;
    max-width: 180px;
}

.form-group-intellect {
    flex: 1;
    min-width: 200px;
}

.intellect-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.intellect-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 0.72rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    min-width: 68px;
    text-align: center;
}

.intellect-chip:has(input:checked) {
    border-color: var(--char-highlight-color, var(--main-color));
    background: rgba(231, 76, 60, 0.15);
}

.intellect-chip input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.intellect-chip-label {
    font-weight: 600;
    color: #fff;
}

.intellect-chip-hint {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.55);
}

.stat-points-badge {
    font-size: 0.72rem;
    font-weight: normal;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 2px 8px;
    margin-left: 6px;
}

.stat-points-badge.stat-points-empty {
    color: rgba(255, 255, 255, 0.45);
}

.skills-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 12px;
}

@media (max-width: 520px) {
    .skills-grid {
        grid-template-columns: 1fr;
    }

    .form-group-compact,
    .form-group-age,
    .form-group-genre,
    .form-group-morpho {
        max-width: none;
        flex: 1 1 100%;
    }
}

.afflictions-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0;
}

.affliction-chip {
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 6px 8px;
    cursor: pointer;
}

.housing-address-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.housing-field {
    width: 100%;
    box-sizing: border-box;
    padding: 8px;
    border-radius: 8px;
}

.housing-street-group {
    width: 100%;
}

.housing-number-group {
    width: 82px;
}

@media (max-width: 520px) {
    .housing-address-row {
        grid-template-columns: 1fr 1fr;
    }
}

.color-pickers input[type="color"] {
    width: 100%;
    height: 36px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.char-submit-btn {
    width: 100%;
    padding: 14px;
    font-size: 1rem;
    background: var(--char-highlight-color, var(--main-color));
    color: white;
    border: 2px solid var(--char-border-color, transparent);
    border-radius: 12px;
    cursor: pointer;
    font-weight: bold;
}

/* Recherche amis (style Facebook) */
.search-results {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 6px;
    max-height: 200px;
    overflow-y: auto;
}

.search-result-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 10px 12px;
    cursor: pointer;
    color: white;
    width: 100%;
}

.search-result-item:hover {
    border-color: var(--main-color);
    background: rgba(255, 255, 255, 0.1);
}

.search-result-item span {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.55);
}

/* Bâtiments ville */
.city-buildings-list {
    max-height: 55vh;
    overflow-y: auto;
}

.city-category {
    margin: 12px 0 6px 0;
    font-size: 0.85rem;
    color: var(--main-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.city-building-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 8px 12px;
    margin-bottom: 6px;
    font-size: 0.85rem;
}

.city-building-card p {
    margin: 4px 0 0 0;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.78rem;
}

.city-building-card .btn-action-small {
    margin-top: 6px;
}

.intellect-chip.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none; /* Empêche les clics */
}

/* Slots Monetag: ad tags are supplied by the publisher dashboard. */
.monetag-slot {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-sizing: border-box;
    color: rgba(255, 255, 255, 0.58);
    background: rgba(255, 255, 255, 0.035);
    border: 1px dashed rgba(255, 255, 255, 0.22);
    font: 0.75rem/1.3 system-ui, sans-serif;
    text-align: center;
}

.monetag-mobile-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    z-index: 30;
    width: 100%;
    height: calc(64px + env(safe-area-inset-bottom));
    padding: 4px 8px env(safe-area-inset-bottom);
    background: rgba(0, 0, 0, 0.94);
    border-top: 1px solid rgba(255, 255, 255, 0.18);
}

.monetag-mobile-banner > * {
    max-width: 100%;
}

.monetag-auth-slot {
    width: 100%;
    min-height: 64px;
    margin: 14px auto 0;
    border-radius: 6px;
}

.monetag-auth-gate {
    position: absolute;
    inset: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.88);
}

.monetag-auth-gate-panel {
    display: grid;
    gap: 14px;
    width: min(100%, 380px);
    padding: 18px;
    color: #fff;
    background: #111;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
}

.monetag-auth-gate-panel h2 {
    margin: 0;
    font-size: 1rem;
}

#monetag-auth-gate-slot {
    min-height: 180px;
    border-radius: 6px;
}

.monetag-desktop-rail {
    display: none; /* caché par défaut, activé via media query si non connecté */
}

/* Slots pubs non configurés (aucun tag dans MONETAG_AD_TAGS) :
   masqués automatiquement — plus de placeholders « Espace
   publicitaire » vides. */
.monetag-slot[data-monetag-configured="false"],
.monetag-mobile-banner[data-monetag-configured="false"] {
    display: none !important;
}

/* Bannière basse : visible uniquement quand un tag y est monté
   (data-monetag-configured="true" posé par monetag_ads.js). */
.monetag-mobile-banner {
    display: none;
}
.monetag-mobile-banner[data-monetag-configured="true"] {
    display: flex;
}

/* Quand la bannière pub basse est réellement affichée, la boîte
   « Etat » et les stats monde remontent juste au-dessus d'elle ;
   sinon elles restent collées en bas de l'écran. */
body:has(.monetag-mobile-banner[data-monetag-configured="true"]) .status-box {
    bottom: calc(68px + env(safe-area-inset-bottom));
}
body:has(.monetag-mobile-banner[data-monetag-configured="true"]) .auth-stats-monde {
    bottom: calc(68px + env(safe-area-inset-bottom, 0px));
}

/* Connecté : masquer uniquement les rails desktop non montés
   (gérés par body.desktop-rails — voir media query ≥980px). */

@media (max-width: 767px) {
    /* Collée en bas de l'écran ; la règle body:has(...) la remonte
       à 68px uniquement quand la bannière pub basse est affichée. */
    .status-box {
        bottom: calc(8px + env(safe-area-inset-bottom));
    }

    #menu-principal {
        /* La bannière stats serveurs (.auth-stats-monde, fixed à
           bottom:92px, ~2-3 lignes sur mobile) recouvre le bas de
           l'écran : padding suffisant pour scroller le contenu
           (dont le bouton « Revoir une pub ») AU-DESSUS d'elle. */
        padding-bottom: calc(180px + env(safe-area-inset-bottom));
    }

    #menu-contenu {
        width: 95%;
        padding: 15px;
    }

    #ecran-parametres,
    #ecran-credits,
    #ecran-scenario,
    #ecran-dynamique {
        padding-bottom: calc(72px + env(safe-area-inset-bottom));
        box-sizing: border-box;
    }

    #formulaire-auth {
        padding-bottom: calc(64px + env(safe-area-inset-bottom));
        box-sizing: border-box;
    }

    #chat-toggle-btn,
    #inventaire-toggle-btn,
    #notifications-toggle-btn {
        bottom: calc(92px + env(safe-area-inset-bottom)) !important;
    }
}

/* Tablettes 768–979px : la bannière mobile est encore affichée
   (le layout desktop à rails ne démarre qu'à 980px) — même réserve
   d'espace qu'en mobile pour ne pas masquer menus, HUD ou boutons. */
@media (min-width: 768px) and (max-width: 979px) {
    /* Bannière pub basse permanente → réserves d'espace et offsets
       applicables connecté ou non. */
    #menu-principal {
        padding-bottom: calc(180px + env(safe-area-inset-bottom));
    }
    #ecran-parametres,
    #ecran-credits,
    #ecran-scenario,
    #ecran-dynamique {
        padding-bottom: calc(72px + env(safe-area-inset-bottom));
        box-sizing: border-box;
    }
    #formulaire-auth {
        padding-bottom: calc(64px + env(safe-area-inset-bottom));
        box-sizing: border-box;
    }
    #chat-toggle-btn,
    #inventaire-toggle-btn,
    #notifications-toggle-btn {
        bottom: calc(92px + env(safe-area-inset-bottom)) !important;
    }
    .status-box {
        bottom: calc(8px + env(safe-area-inset-bottom));
    }
}

/* Mobile + tablette (<980px) : la bannière pub basse et la boîte
   « Etat » sont affichées — les stats monde ne doivent pas être
   fixées en bas d'écran où elles sont masquées. */
@media (max-width: 979px) {
    /* Stats des membres : dans le flux, juste SOUS le cadre du menu
       (plus de position:fixed collée en bas d'écran). */
    #menu-principal #menu-stats-monde {
        position: static;
        transform: none;
        margin: 10px auto 0;
    }
    /* Stats monde de l'écran de connexion : remontées au-dessus de la
       bannière « Etat » (bottom:8px) pour rester visibles. */
    #formulaire-auth #auth-stats-monde {
        bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    }
}

@media (min-width: 980px) {
    /* Layout de base desktop (connecté ou non) */
    body {
        display: grid;
        gap: 18px;
        align-items: center;
        justify-content: center;
        min-height: 100vh;
        min-height: 100dvh;
        overflow: hidden;
        padding: 12px 18px;
    }

    /* Desktop : colonne centrale unique par défaut. Les rails pub
       n'apparaissent que si body.desktop-rails est posé par
       monetag_ads.js — c.-à-d. qu'au moins un slot rail a un vrai
       tag configuré (les slots vides sont masqués partout). */
    body {
        grid-template-columns: minmax(380px, 420px);
    }

    body.desktop-rails {
        grid-template-columns: minmax(200px, 1fr) minmax(380px, 420px) minmax(200px, 1fr);
    }

    #desktop-ad-left,
    #desktop-ad-right {
        display: none;
    }

    body.desktop-rails #desktop-ad-left,
    body.desktop-rails #desktop-ad-right {
        display: flex;
        grid-row: 1;
        flex-direction: column;
        justify-content: center;
        gap: 18px;
        width: 100%;
        height: min(100%, 900px);
        min-width: 0;
        overflow: auto;
    }

    body.desktop-rails #desktop-ad-left { grid-column: 1; }
    body.desktop-rails #desktop-ad-right { grid-column: 3; }

    .monetag-rail-slot {
        width: min(100%, 300px);
        min-width: 160px;
        min-height: 250px;
        margin: 0 auto;
        border-radius: 6px;
    }

    #phone-container {
        grid-column: 1;
        grid-row: 1;
        width: min(100%, 460px);
        height: min(calc(100vh - 24px), 920px);
        height: min(calc(100dvh - 24px), 920px);
        aspect-ratio: 9 / 19.5;
        justify-self: center;
        border: 1px solid rgba(255, 255, 255, 0.22);
        border-radius: 22px;
        box-shadow: 0 18px 60px rgba(0, 0, 0, 0.65);
    }

    /* Rails pub actives : le container passe en colonne centrale */
    body.desktop-rails #phone-container {
        grid-column: 2;
    }

    /* Sur desktop : toujours cacher le banner mobile (les rails remplacent) */
    .monetag-mobile-banner { display: none !important; }

    #ecran-dynamique,
    #ecran-parametres,
    #ecran-credits,
    #ecran-scenario {
        position: absolute;
        width: 100%;
        height: 100%;
        border-radius: inherit;
        overflow: hidden;
    }

    #formulaire-auth,
    .monetag-auth-gate {
        border-radius: inherit;
    }

    /* Stats monde : collées en bas de l'écran sur desktop (pas de
       bannière pub basse — les pubs sont en rails latéraux). */
    .auth-stats-monde {
        bottom: 16px;
    }
}

/* Overlay « pub rewardée » (mock / SDK Monetag) — voir rewarded.js */
.rewarded-overlay {
    position: fixed;
    inset: 0;
    z-index: 10002;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.82);
    transition: opacity 0.25s ease;
}

.rewarded-overlay.cache { opacity: 0; pointer-events: none; }

.rewarded-panel {
    display: grid;
    gap: 14px;
    justify-items: center;
    width: min(92vw, 420px);
    padding: 28px 22px;
    color: #fff;
    background: #14141c;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 12px;
    text-align: center;
    box-sizing: border-box;
}

.rewarded-barre {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 99px;
    overflow: hidden;
}

.rewarded-progression {
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, #7b2ff7, #f107a3);
    transition: width 0.1s linear;
}

.rewarded-compte { font-variant-numeric: tabular-nums; opacity: 0.85; }

.rewarded-skip {
    padding: 8px 18px;
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    cursor: pointer;
}

.rewarded-skip:hover { background: rgba(255, 255, 255, 0.22); }

#btn-pub-recompense {
    border-style: dashed;
}

/* ========== CHAT TEMPS RÉEL (événements fusion:chat) ========== */

#typing-preview {
    padding: 4px 15px;
    font-size: 0.78rem;
    font-style: italic;
    color: rgba(255, 255, 255, 0.55);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    min-height: 0;
    flex-shrink: 0;
}

#typing-preview:empty {
    display: none;
}

.message-auteur {
    font-size: 0.72rem;
    opacity: 0.65;
    margin-bottom: 2px;
    word-break: break-all;
}

.message-texte {
    line-height: 1.35;
}

/* ========== PANNEAU INVENTAIRE (événement fusion:inventaire) ========== */

#inventaire-panel {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 320px;
    max-height: 460px;
    background: #1a1a1a;
    border: 1px solid var(--main-color);
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    z-index: 50;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.5), 0 0 20px var(--main-color);
    overflow: hidden;
}

#inventaire-header {
    background: var(--main-color);
    color: white;
    padding: 10px 14px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

#inventaire-header button {
    background: none;
    border: none;
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0;
    margin: 0;
}

.inventaire-actions {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.inventaire-actions button {
    width: 100%;
    padding: 9px 12px;
    background: var(--main-color);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: bold;
    font-size: 0.88rem;
    cursor: pointer;
    transition: filter 0.2s ease;
}

.inventaire-actions button:hover {
    filter: brightness(1.2);
}

.inventaire-actions button:disabled {
    background: #3a3a3a;
    color: rgba(255, 255, 255, 0.45);
    cursor: not-allowed;
    filter: grayscale(0.6);
}

.inventaire-actions button:disabled:hover {
    filter: none;
}

.inventaire-statut {
    padding: 6px 14px;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
    flex-shrink: 0;
    min-height: 0;
}

.inventaire-statut:empty {
    display: none;
}

.inventaire-liste {
    flex: 1;
    overflow-y: auto;
    padding: 4px 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 0;
}

#notifications-panel {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 320px;
    max-height: 460px;
    background: #1a1a1a;
    border: 1px solid var(--main-color);
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    z-index: 50;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.5), 0 0 20px var(--main-color);
    overflow: hidden;
}

#notifications-header {
    background: var(--main-color);
    color: white;
    padding: 10px 14px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

#notifications-header button {
    background: none;
    border: none;
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0;
    margin: 0;
}

.notif-item {
    display: flex;
    gap: 8px;
    padding: 8px 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    opacity: 0.65;
}

.notif-item:last-child {
    border-bottom: none;
}

.notif-non-lue {
    opacity: 1;
    border-left: 3px solid var(--main-color);
    padding-left: 6px;
}

.notif-icone {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.notif-corps {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.9);
    min-width: 0;
}

.notif-corps span {
    color: rgba(255, 255, 255, 0.75);
}

.notif-corps small {
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.72rem;
}

.inventaire-liste::-webkit-scrollbar {
    width: 4px;
}
.inventaire-liste::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}
.inventaire-liste::-webkit-scrollbar-thumb {
    background: var(--main-color);
    border-radius: 2px;
}

.inventaire-entete {
    font-size: 0.82rem;
    color: var(--main-color);
    font-weight: bold;
    padding: 6px 0 2px;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.15);
    margin-bottom: 2px;
}

.inventaire-monnaie {
    font-size: 0.85rem;
    color: #ffd76a;
    padding: 2px 0;
}

.inventaire-objet {
    font-size: 0.88rem;
    color: #fff;
    padding: 5px 8px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.inventaire-objet:hover {
    border-color: var(--main-color);
}

.inventaire-objet-actions {
    display: inline-flex;
    gap: 4px;
    flex-shrink: 0;
}

.inventaire-action-btn {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: #fff;
    font-size: 0.8rem;
    padding: 2px 6px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.inventaire-action-btn:hover {
    background: var(--main-color);
    border-color: var(--main-color);
}

@media (max-width: 480px) {
    #inventaire-panel {
        right: 12px;
        bottom: 84px;
        width: calc(100vw - 24px);
        max-width: 360px;
    }
}

/* ========== BOUTIQUE CATALOGUE (magasins → articles, boutique_catalogue.js) ========== */

.boutique-titre {
    grid-column: 1 / -1;
    margin: 6px 0 2px;
    color: var(--main-color);
    font-size: 1.25rem;
    text-align: center;
    text-shadow: 0 0 10px var(--main-color);
}

.boutique-sous-titre {
    grid-column: 1 / -1;
    margin: 0 0 8px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.65);
    text-align: center;
}

.boutique-retour {
    grid-column: 1 / -1;
    justify-self: center;
}

/* Cartes des magasins (tous affichés, même vides) */
.boutique-magasin {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 10px;
    background: rgba(255, 255, 255, 0.07);
    border: 2px solid var(--main-color);
    border-radius: 14px;
    color: #fff;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
    text-align: center;
}

.boutique-magasin:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 14px var(--main-color);
    filter: brightness(1.15);
}

.boutique-magasin-vide {
    opacity: 0.65;
    border-style: dashed;
}

.boutique-magasin-icone {
    font-size: 1.8rem;
    line-height: 1;
}

.boutique-magasin-nom {
    font-size: 0.95rem;
}

.boutique-magasin-desc {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.6);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: -webkit-box-orient;
    overflow: hidden;
}

.boutique-magasin-compteur {
    font-size: 0.7rem;
    color: var(--main-color);
    font-weight: 600;
}

/* Onglets d'un magasin (ex. Armes / Protection dans une armurerie) */
.boutique-onglets {
    grid-column: 1 / -1;
    display: flex;
    gap: 8px;
    margin-top: 6px;
}

.boutique-onglet {
    flex: 1;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    color: var(--main-color);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
}

.boutique-onglet.actif {
    background: var(--main-color);
    color: #0b0f1a;
    border-color: var(--main-color);
}

.boutique-onglets-zone {
    grid-column: 1 / -1;
    display: contents;
}

/* Liste des articles : nom + description à gauche, prix à droite */
.boutique-articles {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.boutique-article {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    box-sizing: border-box;
}

.boutique-article-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    flex: 1;
}

.boutique-article-info strong {
    font-size: 0.92rem;
    color: #fff;
}

.boutique-article-info small {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.3;
}

.boutique-article-prix {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    flex-shrink: 0;
}

.boutique-article-prix > strong {
    color: #ffd76a;
    font-size: 0.95rem;
    white-space: nowrap;
}

.boutique-acheter {
    padding: 6px 14px;
    font-size: 0.8rem;
    border-radius: 8px;
    background: var(--main-color);
}

.boutique-indisponible {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
}

.boutique-vide {
    grid-column: 1 / -1;
    margin: 10px 0;
    padding: 16px;
    text-align: center;
    color: rgba(255, 255, 255, 0.65);
    background: rgba(255, 255, 255, 0.05);
    border: 1px dashed rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    font-size: 0.9rem;
}

@media (max-width: 480px) {
    .boutique-magasin {
        padding: 10px 6px;
    }
    .boutique-magasin-icone { font-size: 1.5rem; }
}

/* Listes déroulantes et champs clairs : le navigateur rend le fond
   blanc par défaut — forcer un texte gris foncé pour la lisibilité
   (le blanc hérité était invisible). */
select {
    color: #444;
    background-color: #fff;
}
select option {
    color: #222;
    background: #fff;
}

/* Idem pour les champs texte sans style dédié (fond blanc natif) :
   texte gris foncé. Les champs déjà stylés (.form-group input,
   .real-life-form…, .transfer-dialog…) gardent leur look sombre. */
:where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="button"]):not([type="submit"]):not([type="file"]),
textarea) {
    color: #444;
}

/* Boutons de gestion du groupe secondaire : neutres (pas les couleurs
   du personnage, qui pouvaient être bleues). */
.btn-neutre {
    padding: 10px 8px;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.08);
    color: var(--main-color);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap;
}
.btn-neutre:hover {
    border-color: var(--main-color);
    background: rgba(255, 255, 255, 0.14);
}
.btn-neutre-danger {
    color: #ff7b7b;
}
.btn-neutre-danger:hover {
    border-color: #ff7b7b;
}

/* Statut inline du formulaire d'auth (connexion/résultat) */
.auth-status {
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
}
.auth-statut-ok { color: #2ecc71; }
.auth-statut-ko { color: #ff6b6b; }

/* Stats monde : cadre fixe séparé, sous le cadre invité et toujours
   au-dessus de la bannière pub et du bandeau « Etat ». */
.auth-stats-monde {
    position: fixed;
    /* Collée en bas de l'écran ; la règle body:has(...) la remonte
       à 68px uniquement quand la bannière pub basse est affichée.
       Sur desktop (≥980px) : 16px. */
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 35;
    margin-top: 0;
    padding: 8px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.85rem;
    text-align: center;
    width: fit-content;
    max-width: calc(100% - 24px);
    white-space: normal;
}

/* Sélecteurs arts martiaux / éléments magiques (personnage) */
.catalog-picker{display:flex;flex-wrap:wrap;gap:4px 14px;max-height:170px;overflow-y:auto;padding:4px 2px;}
.picker-item{display:inline-flex;align-items:center;gap:5px;font-size:0.82rem;white-space:nowrap;cursor:pointer;}

/* Champs de stats modifiables (Gérer personnage) */
.stat-edit-row{display:flex;justify-content:space-between;align-items:center;gap:8px;padding:3px 0;font-size:0.85rem;}
.stat-edit-row label{flex:1;}
.stat-edit-row input{width:64px;padding:4px 6px;border-radius:8px;border:1px solid rgba(255,255,255,0.25);background:rgba(255,255,255,0.08);color:inherit;font-size:0.85rem;text-align:center;}
.stat-edit-ro strong{font-size:0.85rem;}
