*{
    box-sizing:border-box;
}

body{
    margin:0;
    font-family:Arial,sans-serif;
    background:
    radial-gradient(circle at top,#2563eb 0%,#020617 70%);
    color:#fff;
    min-height:100vh;
}

.screen{
    display:none;
    padding:20px;
    min-height:100vh;
}

.screen.active{
    display:block;
}

/* ================= LOGIN ================= */

.login-card{
    max-width:420px;
    margin:10vh auto 0;
    background:rgba(15,23,42,.92);
    padding:28px;
    border-radius:28px;
    border:1px solid rgba(255,255,255,.08);
    box-shadow:0 20px 60px rgba(0,0,0,.35);
}

.logo{
    width:90px;
    height:90px;
    margin:0 auto 20px;
    display:flex;
    align-items:center;
    justify-content:center;
    font-size:3rem;
    border-radius:50%;
    background:linear-gradient(135deg,#3b82f6,#22c55e);
}

h1{
    text-align:center;
    margin:0;
    font-size:2rem;
}

.subtitle{
    text-align:center;
    color:#cbd5e1;
    margin-bottom:25px;
}

input{
    width:100%;
    padding:15px;
    border-radius:18px;
    border:none;
    margin-bottom:14px;
    background:rgba(255,255,255,.08);
    color:#fff;
    font-size:1rem;
}

button{
    border:none;
    cursor:pointer;
    font-family:inherit;
}

#login-btn{
    width:100%;
    padding:16px;
    border-radius:18px;
    font-size:1rem;
    font-weight:700;
    background:
    linear-gradient(135deg,#22c55e,#3b82f6);
    color:#fff;
}

#login-error{
    margin-top:15px;
    color:#fecaca;
    text-align:center;
}

/* ================= PASSWORD ================= */

.password-box{
    position:relative;
    margin-bottom:14px;
}

.password-box input{
    margin-bottom:0;
    padding-right:55px;
}

#toggle-password{
    position:absolute;
    top:50%;
    right:14px;
    transform:translateY(-50%);
    background:transparent;
    border:none;
    color:#fff;
    font-size:1.2rem;
}

/* ================= TOPBAR ================= */

.topbar{
    display:flex;
    justify-content:space-between;
    align-items:center;
    margin-bottom:20px;
    padding:14px;
    border-radius:22px;
    background:rgba(15,23,42,.85);
}

.user-box{
    display:flex;
    align-items:center;
    gap:14px;
    min-width:0;
}

#avatar{
    width:54px;
    height:54px;
    border-radius:50%;
    background:#1e293b;
    background-size:cover;
    background-position:center;
    border:2px solid rgba(255,255,255,.2);
    flex-shrink:0;
}

#pseudo{
    font-weight:700;
    font-size:1.05rem;
}

#school{
    font-size:.85rem;
    color:#cbd5e1;
}

#logout-btn{
    padding:10px 14px;
    border-radius:999px;
    background:rgba(255,255,255,.08);
    color:#fff;
}

/* ================= STATS ================= */

.stats{
    display:grid;
    grid-template-columns:repeat(3,1fr);
    gap:12px;
    margin-bottom:20px;
}

.stat-card{
    padding:18px;
    text-align:center;
    border-radius:22px;
    background:rgba(255,255,255,.08);
    font-size:1.4rem;
    font-weight:700;
}

.stat-card span{
    display:block;
    margin-top:8px;
    font-size:1.1rem;
}

/* ================= TITRES ================= */

.section-title{
    margin:10px 0 20px;
}

/* ================= MONDES ================= */

.world-card{
    margin-bottom:18px;
    padding:18px;
    border-radius:24px;
    background:rgba(15,23,42,.85);
    border:1px solid rgba(255,255,255,.08);
}

.world-header{
    display:flex;
    align-items:center;
    gap:10px;
    font-size:1.1rem;
    font-weight:700;
    margin-bottom:16px;
}

.world-icon{
    font-size:1.6rem;
}

.level-grid{
    display:grid;
    grid-template-columns:repeat(2,1fr);
    gap:10px;
}

.level-btn{
    padding:15px;
    border-radius:18px;
    background:rgba(59,130,246,.22);
    color:#fff;
    font-weight:700;
}

/* ================= QUESTIONS ================= */

.question-box{
    margin-top:20px;
    padding:20px;
    border-radius:24px;
    background:rgba(15,23,42,.92);
    position:relative;
    z-index:1;
}

.question-text{
    font-size:1.15rem;
    line-height:1.5;
    font-weight:700;
}

.answers{
    display:grid;
    gap:10px;
    margin-top:18px;
}

.answers button{
    padding:15px;
    border-radius:18px;
    background:rgba(59,130,246,.22);
    color:#fff;
    text-align:left;
    font-size:1rem;
    font-weight:700;
}

.question-img{
    display:block;
    max-width:180px;
    max-height:120px;
    object-fit:contain;
    margin:0 auto 16px;
    background:#fff;
    padding:10px;
    border-radius:16px;
}

/* ================= BOUTON PUB ================= */

.reward-container{
    padding:20px;
    position:relative;
    z-index:9999;
}

#reward-btn{
    width:100%;
    border:none;
    border-radius:22px;
    padding:18px 20px;
    background:linear-gradient(135deg,#7c3aed,#4f46e5);
    color:#fff;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:14px;
    font-size:16px;
    font-weight:700;
    box-shadow:0 10px 30px rgba(79,70,229,.35);
    position:relative;
    z-index:99999;
}

#reward-btn:active{
    transform:scale(.98);
}

.reward-icon,
.reward-heart{
    font-size:28px;
}

.reward-text{
    flex:1;
    text-align:left;
    line-height:1.2;
}

.reward-text small{
    display:block;
    font-size:12px;
    opacity:.85;
    margin-top:4px;
}

/* ================= BOUTON CLASSEMENT ================= */

.leaderboard-container{
    padding:20px;
    position:relative;
    z-index:9999;
}

#leaderboard-btn{
    width:100%;
    border:none;
    border-radius:22px;
    padding:18px 20px;
    background:linear-gradient(135deg,#f59e0b,#f97316);
    color:#fff;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:14px;
    font-size:16px;
    font-weight:700;
    box-shadow:0 10px 30px rgba(249,115,22,.35);
    position:relative;
    z-index:99999;
}

#leaderboard-btn:active{
    transform:scale(.98);
}

.leaderboard-icon,
.leaderboard-star{
    font-size:28px;
}

.leaderboard-text{
    flex:1;
    text-align:left;
    line-height:1.2;
}

.leaderboard-text small{
    display:block;
    font-size:12px;
    opacity:.85;
    margin-top:4px;
}

/* ================= LEADERBOARD ================= */

.leaderboard-box{
    margin:20px;
    padding:22px;
    border-radius:28px;
    background:rgba(15,23,42,.92);
    color:#fff;
}

.back-btn{
    border:none;
    border-radius:999px;
    padding:12px 18px;
    margin-bottom:22px;
    background:#1d4ed8;
    color:#fff;
    font-weight:800;
}

/* ================= LEADERBOARD MOBILE ================= */

.leaderboard-box{
    margin:4px;
    padding:10px;
    border-radius:26px;
    background:rgba(15,23,42,.95);
    color:#fff;
}

.leaderboard-list{
    display:flex;
    flex-direction:column;
    gap:10px;
}

.leaderboard-row{
    display:flex;
    align-items:center;
    gap:7px;
    width:100%;
    min-height:68px;
    padding:10px 10px;
    border-radius:20px;
    background:rgba(255,255,255,.08);
    overflow:hidden;
}

.leaderboard-rank{
    width:34px;
    font-size:16px;
    font-weight:900;
    flex-shrink:0;
}

.leaderboard-avatar{
    width:48px;
    height:48px;
    border-radius:15px;
    background:#334155;
    background-size:cover;
    background-position:center;
    display:flex;
    align-items:center;
    justify-content:center;
    font-size:24px;
    flex-shrink:0;
}

.leaderboard-info{
    flex:1;
    min-width:0;
    overflow:hidden;
}

.leaderboard-info strong{
    display:block;
    font-size:15px;
    font-weight:900;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
}

.leaderboard-info small{
    display:block;
    margin-top:2px;
    font-size:10px;
    color:rgba(255,255,255,.72);
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
}

.leaderboard-info span{
    display:block;
    margin-top:2px;
    font-size:10px;
    font-weight:700;
    color:#cbd5e1;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
}

.leaderboard-xp{
    width:58px;
    text-align:right;
    font-size:14px;
    font-weight:900;
    color:#facc15;
    flex-shrink:0;
}

.send-life-small-btn{
    width:40px;
    height:40px;
    border:none;
    border-radius:14px;
    background:linear-gradient(135deg,#ff4d6d,#ff758f);
    color:#fff;
    font-size:19px;
    flex-shrink:0;
    box-shadow:0 6px 16px rgba(255,77,109,.28);
}

.send-life-small-btn:active{
    transform:scale(.95);
}

.leaderboard-head{
    display:grid;
    grid-template-columns:34px 1fr 58px;
    gap:10px;
    padding:0 14px 8px;
    color:rgba(255,255,255,.65);
    font-size:12px;
    font-weight:800;
}

.topbar-actions{
    display:flex;
    align-items:center;
    gap:8px;
}

#exit-app-btn{
    border:none;
    border-radius:14px;
    width:42px;
    height:42px;
    background:rgba(255,255,255,.08);
    color:#fff;
    font-size:18px;
    font-weight:800;
}

#logout-btn{
    white-space:nowrap;
}

.question-topbar{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    margin-bottom:16px;
}

.question-topbar h2{
    margin:0;
}

.quit-challenge-btn{
    border:none;

    width:42px;
    height:42px;

    border-radius:14px;

    background:linear-gradient(135deg,#ef4444,#dc2626);

    color:#fff;

    font-size:18px;
    font-weight:900;

    box-shadow:0 8px 18px rgba(239,68,68,.28);
}

/* ================= EDUQUIZ NIVEAUX / MONDES ================= */

#school-levels{
    display:flex;
    gap:10px;
    overflow-x:auto;
    padding:4px 2px 14px;
    margin-top:4px;
    scrollbar-width:none;
}

#school-levels::-webkit-scrollbar{
    display:none;
}

.school-level-btn{
    min-width:64px;
    padding:12px 16px;
    border-radius:999px;
    background:rgba(255,255,255,.10);
    color:#fff;
    font-size:16px;
    font-weight:900;
    box-shadow:inset 0 0 0 1px rgba(255,255,255,.08);
    white-space:nowrap;
}

.school-level-btn.active{
    background:linear-gradient(135deg,#facc15,#f97316);
    color:#111827;
    box-shadow:0 10px 24px rgba(250,204,21,.28);
}

#world-tabs{
    display:flex;
    gap:10px;
    overflow-x:auto;
    padding:0 2px 16px;
    scrollbar-width:none;
}

#world-tabs::-webkit-scrollbar{
    display:none;
}

.world-tab-btn,
.world-random-btn{
    flex:0 0 auto;
    padding:11px 14px;
    border-radius:999px;
    background:rgba(15,23,42,.82);
    color:#fff;
    font-size:14px;
    font-weight:800;
    border:1px solid rgba(255,255,255,.08);
    box-shadow:0 8px 20px rgba(0,0,0,.18);
}

.world-random-btn{
    background:linear-gradient(135deg,#22c55e,#06b6d4);
}

.world-tab-btn.active{
    background:linear-gradient(135deg,#7c3aed,#2563eb);
    border-color:rgba(255,255,255,.25);
}

.world-tab-btn.locked{
    opacity:.65;
}

.active-world-card .world-header{
    align-items:flex-start;
}

.active-world-card .world-header small{
    display:block;
    margin-top:5px;
    color:#cbd5e1;
    font-size:12px;
}

.world-progress{
    width:100%;
    height:10px;
    border-radius:999px;
    background:rgba(255,255,255,.10);
    overflow:hidden;
    margin:0 0 16px;
}

.world-progress span{
    display:block;
    height:100%;
    border-radius:999px;
    background:linear-gradient(135deg,#22c55e,#facc15);
}

.empty-world{
    padding:18px;
    border-radius:22px;
    background:rgba(15,23,42,.85);
    color:#cbd5e1;
    font-weight:800;
    text-align:center;
}

.school-level-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.school-thumb {
    width: 28px;
    height: 28px;
    border-radius: 10px;
    overflow: hidden;
    flex: 0 0 28px;
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.18);
}

.school-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.school-label {
    white-space: nowrap;
}

.world-tab-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.world-thumb {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    overflow: hidden;
    flex: 0 0 42px;
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.18);
}

.world-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.world-emoji {
    font-size: 22px;
    line-height: 1;
}

.world-title {
    white-space: nowrap;
}

.google-login-btn {
    width: 100%;
    border: 0;
    border-radius: 18px;
    padding: 14px 18px;
    margin-top: 12px;
    background: #ffffff;
    color: #111827;
    font-weight: 900;
    font-size: 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
}

.google-login-btn:active {
    transform: scale(0.98);
}

.google-login-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-grid;
    place-items: center;
    background: #f3f4f6;
    color: #2563eb;
    font-weight: 900;
}

/* ==============================
   Connexion Google
============================== */

.google-login-btn {
    width: 100%;
    border: 0;
    border-radius: 18px;
    padding: 14px 18px;
    margin-top: 12px;
    background: #ffffff;
    color: #111827;
    font-weight: 900;
    font-size: 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
}

.google-login-btn:active {
    transform: scale(0.98);
}

.google-login-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-grid;
    place-items: center;
    background: #f3f4f6;
    color: #2563eb;
    font-weight: 900;
    font-size: 17px;
}

/* ==============================
   Boutons secondaires
============================== */

.secondary-btn {
    width: 100%;
    border: 0;
    border-radius: 18px;
    padding: 13px 18px;
    margin-top: 12px;
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
    font-weight: 900;
    font-size: 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
    backdrop-filter: blur(8px);
}

.secondary-btn:active {
    transform: scale(0.98);
}

/* ==============================
   Écran inscription
============================== */

#register-screen .login-card {
    max-width: 430px;
    width: min(92vw, 430px);
    padding-bottom: 26px;
}

#register-screen input,
#register-screen select {
    width: 100%;
    border: 0;
    outline: none;
    border-radius: 16px;
    padding: 14px 16px;
    margin-top: 10px;
    background: rgba(255, 255, 255, 0.94);
    color: #111827;
    font-size: 15px;
    font-weight: 700;
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.25);
}

#register-screen input::placeholder {
    color: #64748b;
    font-weight: 700;
}

#register-screen select {
    appearance: none;
    cursor: pointer;
}

#register-submit-btn {
    width: 100%;
    border: 0;
    border-radius: 18px;
    padding: 15px 18px;
    margin-top: 14px;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #ffffff;
    font-weight: 900;
    font-size: 16px;
    box-shadow: 0 14px 30px rgba(22, 163, 74, 0.28);
}

#register-submit-btn:active {
    transform: scale(0.98);
}

/* ==============================
   Adaptation petits écrans
============================== */

@media (max-width: 420px) {
    #register-screen .login-card {
        padding: 22px 18px;
    }

    #register-screen input,
    #register-screen select {
        padding: 13px 14px;
        font-size: 14px;
    }

    .google-login-btn,
    .secondary-btn,
    #register-submit-btn {
        font-size: 14px;
        padding: 13px 14px;
    }
}

#app-loading {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(2, 6, 23, 0.78);
    backdrop-filter: blur(8px);
}

.app-loading-box {
    width: min(86vw, 340px);
    padding: 26px 22px;
    border-radius: 28px;
    background: linear-gradient(135deg, #1e3a8a, #4c1d95);
    color: #fff;
    text-align: center;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.app-loading-spinner {
    width: 54px;
    height: 54px;
    margin: 0 auto 16px;
    border-radius: 50%;
    border: 5px solid rgba(255, 255, 255, 0.25);
    border-top-color: #ffffff;
    animation: appSpin 0.9s linear infinite;
}

#app-loading-text {
    font-size: 18px;
    font-weight: 800;
}

@keyframes appSpin {
    to {
        transform: rotate(360deg);
    }
}
/* ==============================
   Connexion Apple (iPhone uniquement)
============================== */

.apple-login-btn {
    width: 100%;
    border: 0;
    border-radius: 18px;
    padding: 14px 18px;
    margin-top: 12px;
    background: #000000;
    color: #ffffff;
    font-weight: 900;
    font-size: 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
}

.apple-login-btn[hidden],
.google-login-btn[hidden] {
    display: none;
}

.apple-login-btn:active {
    transform: scale(0.98);
}

.apple-login-icon {
    font-size: 20px;
    line-height: 1;
}

/* ==============================
   Suppression du compte
============================== */

.account-danger-zone {
    margin: 32px 0 24px;
    text-align: center;
}

.delete-account-btn {
    border: 1px solid rgba(239, 68, 68, 0.6);
    border-radius: 999px;
    padding: 10px 18px;
    background: transparent;
    color: #ef4444;
    font-weight: 700;
    font-size: 14px;
}

.delete-account-btn:active {
    transform: scale(0.98);
}

/* ==============================
   Version web installable (PWA)
============================== */

[hidden] {
    display: none !important;
}

/* Encoche / barre d'etat en mode plein ecran (iPhone) */
.screen {
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
}

.google-web-btn {
    display: flex;
    justify-content: center;
    margin-top: 12px;
    min-height: 44px;
}

.install-banner {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    padding-top: max(12px, env(safe-area-inset-top));
    background: #1d4ed8;
    color: #ffffff;
    font-size: 14px;
    line-height: 1.4;
    box-shadow: 0 8px 20px rgba(2, 6, 23, 0.35);
}

.install-icon {
    font-size: 22px;
    flex-shrink: 0;
}

.install-text {
    flex: 1;
}

.install-btn {
    border: 0;
    border-radius: 999px;
    padding: 8px 14px;
    background: #ffffff;
    color: #1d4ed8;
    font-weight: 800;
    flex-shrink: 0;
}

.install-close {
    border: 0;
    background: transparent;
    color: #ffffff;
    font-size: 16px;
    padding: 4px 6px;
    flex-shrink: 0;
}
