/* BAses du site */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* Permet d'inclure le padding dans la largeur/hauteur */
    touch-action: manipulation;
    /* Bloque le zoom accidentel sur mobile lors des "double-tap" */
}

html,
body {
    margin: 0;
    /* 100vh pose problème sur Safari mobile à cause de la barre d'URL. 
       100dvh c'est la solution idéale */
    height: 100vh;
    height: 100dvh;
    width: 100%;
    overflow-x: hidden;
    /* Empêche le scroll horizontal accidentel */
    font-family: 'Inter Tight', sans-serif;
    display: flex;
    flex-direction: column;
    /* Empêche iOS de zoomer automatiquement les textes quand on tourne l'écran */
    -webkit-text-size-adjust: 100%;
}


/* Header */

header {
    width: 100%;
    display: flex;
    align-items: center;
    padding: 3vw 5vw;
    justify-content: space-between;
    flex-shrink: 0;
    /* Empêche le header de s'écraser si le contenu en dessous est trop grand */
    background-color: #ffffff;
    z-index: 1000;
    user-select: none;
    /* Empêche la sélection de texte accidentelle au clic */
    -webkit-user-select: none;
}

header a {
    display: flex;
    align-items: center;
    -webkit-tap-highlight-color: transparent;
}

header .logo-text {
    width: 30vw;
    height: auto;
    pointer-events: none;
    /* Empêche de glisser l'image accidentellement ou de faire un clic droit dessus */
}


/* L'icône de déconnexion/connexion SVG */
header #logout {
    width: 8vw;
    max-width: 40px;
    height: auto;
    cursor: pointer;
}

header #logout img {
    width: 7vw;
    max-width: 35px;
    cursor: pointer;
    transition: transform 0.2s;
}


/* Partie principale*/

.body {
    width: 100%;
    flex-grow: 1;
    /* Prend tout l'espace disponible entre le header et le footer */
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 5vw;
    overflow-y: auto;
    /* Active le scroll vertical uniquement si le contenu dépasse (Formulaires, Avatars...) */
    -webkit-overflow-scrolling: touch;
    /* Rend le "défilement fluide sur iPhone */


    padding: 4vw 5vw calc(110px + env(safe-area-inset-bottom)) 5vw;
    /* Vital pour l'iPhone X et ultérieurs pour eviter la bare noir automatiquedu footer */
}

/* Masque la barre de défilement */
.body::-webkit-scrollbar {
    display: none;
}


/* Accueil */

.logo {
    width: auto;
    max-width: 85%;
    max-height: 25vh;
    object-fit: contain;/* S'assure que l'image n'est pas déformée */
    margin: 0 auto;
    display: block;
}

.buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 4vw;
    margin: 0;
}

.register-btn,
.login-btn,
.game-btn {
    -webkit-appearance: none;
    appearance: none;
    border: 2px solid #cc1b30;
    border-radius: 20px;
    background-color: transparent;
    width: 60vw;
    font-size: 6vw;
    padding: 3vw;
    color: #cc1b30;
    text-decoration: none;
    display: block;
    text-align: center;
    cursor: pointer;
    margin: 0;
}


/* Formulaire de salons */

form {
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    flex-grow: 1;
    height: 100%;
}

h1 {
    text-align: center;
    margin: 0;
}

label {
    font-weight: 900;
}

.input {
    padding: 12px;
    margin-top: 2vw;
    background-color: #cc1b3060;
    color: #ffffff;
    border-radius: 10vw;
    overflow: hidden;
}

/* Hack CSS TRÈS IMPORTANT : Gère la couleur que Chrome met quand il auto-remplit les mots de passe et emails */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    -webkit-text-fill-color: #000000;
    -webkit-box-shadow: 0 0 0px 1000px transparent inset;
    transition: background-color 5000s ease-in-out 0s;
}

.pseudo-container,
.email-container {
    margin-bottom: 0;
    width: 100%;
}

#pseudo,
#email {
    -webkit-appearance: none;
    appearance: none;
    background-color: transparent;
    border: transparent;
    height: 8vw;
    width: 100%;
    outline: none; /* Enlève la bordure bleue au clic par défaut */
}

.login,
.register {
    text-align: center;
    margin: 0;
    font-size: 3.5vw;
    border: none;
    background: none;
}

.login a,
.register a {
    text-decoration: none;
    color: #cc1b30;
}

.message-success {
    color: #4b8549;
    text-align: center;
    font-weight: bold;
    margin: 2vw 0;
}

.message-error {
    color: #e74c3c;
    text-align: center;
    font-weight: bold;
    margin: 2vw 0;
}


/* Page jeu */

#logo-lobby {
    width: 80vw;
    max-width: 350px;
    height: auto;
    max-height: 35vh;
    margin: 0 auto 4vw auto;
    display: block;
}

.welcome {
    color: #cc1b30;
    font-size: 10vw;
    font-weight: bold;
    text-align: center;
    margin: 0 auto;
}

.profils-img {
    margin: 0 auto;
}

.profils-img img {
    height: 10vw;
    display: block;
    margin: 0 auto;
}

.big-profil {
    background-color: #cc1b3040;
    border-radius: 100%;
    padding: 4vw;
    margin: 0 auto;
    width: fit-content; /* Le conteneur s'adapte exactement à la taille de l'image */
}

.big-profil img {
    height: 50vw;
    display: block;
    margin: 0 auto;
}

.proposition-profils {
    margin: 0 auto;
}


/* Création des salons*/

.header-titles {
    text-align: center;
    margin: 0 0 5vw 0;
}

.title-main {
    font-size: 8vw;
    font-weight: 800;
    color: #000000;
    line-height: 1.1;
    letter-spacing: -1px;
    margin: 0;
}

.section-title {
    font-size: 4.5vw;
    font-weight: 400;
    color: #000000;
    margin-bottom: 2vw;
    text-align: left;
}

.section-block {
    margin-bottom: 4vw;
    width: 100%;
}

.room-list {
    display: flex;
    flex-direction: column;
    gap: 4vw;
}

.room-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 2px solid #cc1b30;
    border-radius: 25px;
    padding: 2vw 3vw 2vw 5vw;
    background-color: #ffffff;
}

.room-item .room-name {
    font-size: 4vw;
    color: #000000;
}

.room-item button {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    border: 1.5px solid #cc1b30;
    border-radius: 20px;
    padding: 1.5vw 4vw;
    font-size: 3.5vw;
    font-weight: 500;
    color: #000000;
    cursor: pointer;
    transition: all 0.2s ease;
}

.room-item button:active {
    background-color: #f0f0f0;
}

.creation-form {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.creation-form label {
    font-size: 3.5vw;
    color: #000000;
    margin-bottom: 2vw;
}

.creation-form input[type="text"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background-color: #f4b8be;
    border: none;
    border-radius: 20px;
    padding: 3vw 5vw;
    font-size: 4vw;
    color: #666666;
    margin-bottom: 4vw;
    outline: none;
}

.creation-form input[type="text"]::placeholder {
    color: #cc666e;
    opacity: 0.7;
}

.btn-center {
    display: flex;
    justify-content: center;
    width: 100%;
}

.btn-create {
    -webkit-appearance: none;
    appearance: none;
    background: #ffffff;
    border: 2px solid #cc1b30;
    border-radius: 20px;
    padding: 2.5vw 6vw;
    font-size: 4vw;
    font-weight: 500;
    color: #000000;
    cursor: pointer;
}


/* Jeu en cours (arène)*/

.game-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin: 2vw 0 4vw 0;
}

.player-slot {
    display: flex;
    align-items: center;
    gap: 2vw;
    width: 35%;
}

.player-slot.right {
    justify-content: flex-end;
}

.avatar-circle {
    width: 12vw;
    height: 12vw;
    background-color: #cc1b3060;
    border: 2px solid #cc1b30;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    flex-shrink: 0;
}

.player-info-text {
    display: flex;
    flex-direction: column;
}

.text-right {
    text-align: right;
}

.player-name {
    font-size: 2.5vw;
    font-weight: 700;
    color: #000000;
}

.player-score {
    font-size: 3vw;
    font-weight: 500;
    color: #000000;
}

.timer-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 25%;
}

.timer-circle {
    width: 16vw;
    height: 16vw;
    border: 3px solid #cc1b30;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 7vw;
    font-weight: 800;
    color: #000000;
}

.question-header-title {
    font-size: 4.5vw;
    font-weight: 800;
    color: #000000;
    text-align: center;
    margin-bottom: 4vw;
}

.category-header-title {
    text-align: center;
    margin: 4vw 0;
}

.category-header-title .txt-win {
    font-size: 7vw;
    font-weight: 500;
    color: #000000;
    margin: 0;
    line-height: 1.1;
}

.category-header-title .txt-sub {
    font-size: 6.5vw;
    font-weight: 400;
    color: #000000;
    margin: 2vw 0 0 0;
    line-height: 1.2;
}

.ui-winner-label {
    font-size: 4.5vw;
    font-weight: 700;
    color: #cc1b30;
    text-align: center;
    margin-bottom: 3vw;
    text-transform: uppercase;
}

.question-statement-box {
    background-color: #f4b8be;
    border-radius: 25px;
    padding: 6vw 5vw;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 4vw;
}

.question-statement-box p {
    font-size: 3.5vw;
    font-weight: 500;
    color: #000000;
    text-align: center;
    line-height: 1.2;
    margin: 0;
}

.answers-stack {
    display: flex;
    flex-direction: column;
    gap: 3vw;
    width: 100%;
}

.btn-answer-stacked {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background-color: #ffffff;
    border: 2px solid #cc1b30;
    border-radius: 25px;
    padding: 3.5vw 4vw;
    font-size: 4vw;
    font-weight: 400;
    color: #000000;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    outline: none;
    word-wrap: break-word; /* Permet au texte de passer à la ligne s'il est trop long au lieu de dépasser du bouton */
}

/* Modificateurs gérés par JavaScript lors des clics sur les réponses */
.btn-answer-stacked.selected {
    background-color: #f0f0f0 !important;
    border-color: #999999 !important;
    color: #333333 !important;
}

.btn-answer-stacked.correct {
    background-color: #2bb94c !important;
    border-color: #cc1b30 !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    opacity: 1 !important;
}

.btn-answer-stacked.wrong {
    background-color: #cc1b3040 !important;
    border-color: #cc1b30 !important;
    color: #cc1b30 !important;
    font-weight: 700 !important;
    opacity: 1 !important;
}

.answers-stack button:disabled {
    cursor: default;/* Enlève l'icône de la petite main (pointer) si le bouton n'est plus cliquable */
}

.btn-quit-wrapper {
    display: flex;
    justify-content: center;
    margin-top: 4vw;
}

.btn-quit-maquette {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    border: none;
    color: #999999;
    font-size: 3.5vw;
    text-decoration: underline;
    cursor: pointer;
}


/* Compte utilisateur */

.account-pseudo {
    text-align: center;
    font-size: 9vw;
    font-weight: 500;
    color: #222;
    margin: 4vw 0 1vw 0;
    letter-spacing: -1px;
}

.account-score {
    text-align: center;
    font-size: 6.5vw;
    font-weight: 500;
    color: #333;
    margin-bottom: 4vw;
}

.account-instruction {
    text-align: center;
    font-size: 4.5vw;
    font-weight: 400;
    color: #333;
    margin: 0 10vw 4vw 10vw;
    line-height: 1.3;
}

.account-big-avatar {
    width: 45vw;
    height: 45vw;
    max-width: 200px;
    max-height: 200px;
    background-color: #fce8ea;
    border: 2px solid #cc1b30;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 6vw auto;
}

.account-big-avatar svg {
    width: 65%;
    height: auto;
}


.account-avatars-list {
    display: flex;
    justify-content: center;
    gap: 5vw;
    margin-bottom: 6vw;
}

.account-small-avatar {
    width: 18vw;
    height: 18vw;
    max-width: 80px;
    max-height: 80px;
    background-color: #fce8ea;
    border: 2px solid #cc1b30;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.account-small-avatar:active {
    transform: scale(0.6);
}

.account-big-avatar .big-avatar-svg.active {
    display: block;
}


.account-small-avatar svg {
    width: 60%;
    height: auto;
}

.account-infos {
    text-align: center;
    font-size: 4.5vw;
    color: #333;
    line-height: 1.5;
    margin-bottom: 4vw;
}

.account-infos strong {
    font-weight: 800;
}


/* Classement */

.body-leaderboard {
    width: 100%;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 2vw 5vw calc(100px + env(safe-area-inset-bottom)) 5vw;
}

.page-title {
    text-align: center;
    font-size: 8vw;
    font-weight: 900;
    color: #cc1b30;
    margin: 0 0 4vw 0;
    text-transform: uppercase;
    flex-shrink: 0;
}

/* La zone des scores (C'est uniquement elle, qui va scroller !) */
.leaderboard-container {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Rend le scroll ultra fluide sur iOS */
}

.leaderboard-container::-webkit-scrollbar {
    display: none;
}

/* LE PODIUM (Top 3) */
.podium-wrapper {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 2vw;
    height: 50vw;
    max-height: 250px;
    margin-bottom: 6vw;
    border-bottom: 3px solid #eee;
    flex-shrink: 0;
}

.podium-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: 30%;
    border-radius: 15px 15px 0 0;
    padding: 3vw 1vw;
    text-align: center;
    position: relative;
}

.pod-rank {
    font-size: 8vw;
    font-weight: 900;
    margin-bottom: 2vw;
    line-height: 1;
}

.pod-rank svg.icon-trophee {
    height: 8vw;
    width: auto;
    /* Garde les proportions */
}

.class-rank svg.icon-trophee {
    height: 5vw;
    width: auto;
}

.pod-name {
    font-size: 2.2vw;
    font-weight: bold;
    width: 95%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 1vw;
}

.pod-score {
    font-size: 3.6vw;
    font-weight: 900;
    margin-top: auto;
}

.pod-moi-txt {
    font-size: 2vw;
    opacity: 0.9;
    color: #2bb94c;
}

.step-1 {
    height: 100%;
    order: 2;
    background-color: #fce8ea;
    border: 2px solid #cc1b30;
    border-bottom: none;
    color: #cc1b30;
    z-index: 2;
}

.step-2 {
    height: 75%;
    order: 1;
    /* Le 2ème passe à gauche */
    background-color: #fce8ea;
    border: 2px solid #cc1b30;
    border-bottom: none;
    color: #cc1b30;
    z-index: 1;
}

.step-3 {
    height: 60%;
    order: 3;
    /* Le 3ème passe à droite */
    background-color: #fce8ea;
    border: 2px solid #cc1b30;
    border-bottom: none;
    color: #cc1b30;
    z-index: 1;
}

/* Styles quand l'utilisateur actuel est sur le podium */
.step-1.is-me {
    border: 3px solid #2bb94cc1;
    color: #2bb94c;
    box-shadow: 0 -4px 10px rgba(43, 185, 76, 0.3);
}

.step-2.is-me,
.step-3.is-me {
    border-color: #2bb94c;
    color: #2bb94c;
}

.list-wrapper {
    display: flex;
    flex-direction: column;
    gap: 3vw;
}

.class-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: white;
    border: 2px solid #cc1b30;
    border-radius: 50px;
    padding: 3vw 6vw;
    font-family: 'Arial', sans-serif;
    font-weight: bold;
    flex-shrink: 0;
}

.class-rank {
    font-size: 5.5vw;
    color: #cc1b30;
    width: 12vw;
    text-align: left;
}

.class-name {
    flex-grow: 1;
    text-align: center;
    font-size: 4.5vw;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.class-score {
    font-size: 4.5vw;
    color: #333;
    width: 18vw;
    text-align: right;
}

.class-item.is-me {
    border-color: #2bb94c;
    background-color: #f0fdf4;
}

.class-item.is-me .class-rank {
    color: #2bb94c;
}

.class-item.is-me .class-name {
    color: #2bb94c;
}

.txt-moi {
    font-size: 0.8em;
    font-weight: normal;
    opacity: 0.9;
}


/* Footer */

.navigation {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 90px;
    background: #cc1b30;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    z-index: 999;
    padding-bottom: env(safe-area-inset-bottom);/* Très important pour la barre Home de l'iPhone */
}

.navigation ul {
    display: flex;
    width: 100%;
    max-width: 500px;
    padding: 0;
    margin: 0;
    position: relative;
}

.navigation ul li {
    list-style: none;
    flex: 1;
    height: 60px;
    z-index: 1;
    -webkit-tap-highlight-color: transparent;
}

.navigation ul li a {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    text-decoration: none;
}

.navigation ul li.active a .icon {
    position: absolute;
    background: #fff;
    color: #cc1b30;
    width: 55px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 0 0 25px 25px;
    z-index: 10;
}

.nav-svg {
    width: 24px;
    height: 24px;
    transition: 0.3s;
    filter: brightness(0) invert(1);
    /* Transforme le SVG noir en SVG blanc */
}

/* La bulle blanche quand le menu est actif */
.navigation ul li.active a .icon {
    position: absolute;
    background: #fff;
    width: 65px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 0 0 25px 25px;
    transition: 0.3s;
    z-index: 10;
}

.navigation ul li.active a .icon .nav-svg {
    /* On annule le filtre blanc l'icône retrouve son rouge d'origine */
    filter: none;
}

.footer-text {
    position: absolute;
    bottom: calc(8px + env(safe-area-inset-bottom));
    width: 100%;
    text-align: center;
    color: white;
    font-size: 10px;
    opacity: 0.8;
    pointer-events: none;
}

/* Mode hors ligne */

#offline-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 15, 15, 0.95);
    /* Fond très sombre mais légèrement transparent */
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    /* Rend l'overlay invisible et incliquable quand il n'est pas actif */
}

#offline-overlay.active {
    opacity: 1;
    visibility: visible;
}

.offline-content {
    text-align: center;
    display: flex !important;
    flex-direction: column !important;
    align-items: center;
    justify-content: center;
    gap: 15px;
    width: 90vw;
}

#offline {
    height: 30vw;
    margin: 5vw;
}

.offline-btn {
    -webkit-appearance: none;
    appearance: none;
    border: 2px solid #cc1b30;
    border-radius: 20px;
    background-color: white;
    width: 60vw;
    font-size: 4vw;
    padding: 3vw;
    color: #cc1b30;
    text-decoration: none;
    display: block;
    text-align: center;
    cursor: pointer;
    margin: 5vw;
}

#offline-overlay.active.minimized {
    position: fixed !important;
    /* FORCE la bannière à rester totalement figée à l'écran */
    top: auto !important;
    bottom: 90px !important;
    /* Reste pile au-dessus du footer (90px) */
    left: 0 !important;
    width: 100% !important;
    height: 60px !important;
    background-color: #cc1b30;
    z-index: 10000;

}

#offline-overlay.minimized .offline-content {
    flex-direction: row !important;
    justify-content: center;
    align-items: center;
    gap: 3vw;
    width: 90vw;
    height: 100%;
    padding: 0 4vw;
}

#offline-overlay.minimized #offline {
    height: 6vw;
    max-height: 25px;
    margin: 0;
}

#offline-overlay.minimized .offline-btn {
    width: auto;
    font-size: 3.5vw;
    padding: 1.5vw 4vw;
    margin: 0;
    border-radius: 10px;
    background-color: white;
    color: #cc1b30;
}