/* UI "mobile game" (dark) - Thème Hordes */
:root{
  --bg:#0b1020;
  --panel:#121a33;
  --panel2:#0f1630;
  --text:#f1f5f9;
  --muted:#a9b4d6;
  --brand:#fbbf24;
  --brand2:#f59e0b;
  --danger:#dc2626;
  --ok:#34d399;
  --border:rgba(251,191,36,.2);
  --shadow: 0 18px 60px rgba(0,0,0,.45);
}
 *{box-sizing:border-box}
 html{
   min-height: 100%;
   height: 100%;
   overflow-x: hidden;
   overflow-y: auto;
   /* S'assurer que le scroll se fait sur html, pas sur body */
   position: relative;
   background: linear-gradient(135deg, #1a1a2e 0%, #16213e 25%, #0f3460 50%, #1a1a2e 75%, #16213e 100%);
   background-size: 400% 400%;
   animation: gradientFlow 20s ease infinite;
   background-repeat:no-repeat;
   background-attachment: fixed;
 }
 @keyframes gradientFlow {
   0%, 100% { background-position: 0% 50%; }
   50% { background-position: 100% 50%; }
 }
 html::before {
   content: '';
   position: fixed;
   top: 0;
   left: 0;
   width: 100%;
   height: 100%;
   background: 
     radial-gradient(circle at 20% 30%, rgba(220, 38, 38, 0.15) 0%, transparent 50%),
     radial-gradient(circle at 80% 70%, rgba(139, 69, 19, 0.1) 0%, transparent 50%);
   pointer-events: none;
   z-index: 0;
   /* S'assurer que ce pseudo-élément n'interfère pas avec position:fixed */
   transform: none;
   will-change: auto;
 }
 /* Wrapper pour limiter la largeur du contenu */
 body::before {
   content: '';
   position: fixed;
   top: 0;
   left: 0;
   right: 0;
   bottom: 0;
   background: rgba(0, 0, 0, 0.3);
   z-index: -1;
   pointer-events: none;
 }
 body{
   margin:0;
   font-family:system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,Noto Sans,sans-serif;
   -webkit-font-smoothing: antialiased;
   -moz-osx-font-smoothing: grayscale;
   background:transparent;
   color:var(--text);
   overscroll-behavior: none;
   position: static;
   z-index: 1;
   /* Limiter la largeur à celle d'un téléphone et centrer */
   max-width: 420px;
   margin: 0 auto;
   width: 100%;
   min-height: 100vh;
   min-height: 100dvh;
   overflow-x: hidden;
   overflow-y: visible;
   /* Le scroll se fait sur html, pas sur body */
   box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.15);
   background: rgba(26, 26, 46, 0.3);
   /* NE PAS utiliser backdrop-filter sur body car ça casse position:fixed */
   /* backdrop-filter: blur(10px); */
   /* S'assurer que le body ne force pas de scroll inutile */
   padding-bottom: 0;
   /* Ne pas créer de contexte de positionnement qui affecte position:fixed */
   transform: none;
   perspective: none;
   will-change: auto;
   filter: none;
 }
 /* Sur mobile, le body prend toute la largeur */
 @media (max-width: 420px) {
   body {
     max-width: 100%;
     box-shadow: none;
   }
 }
a{color:var(--brand); transition: color 0.2s ease;}
a:hover{color:#f59e0b;}
.container{
  max-width:420px;
  margin:0 auto;
  padding:14px 14px calc(96px + env(safe-area-inset-bottom)) 14px;
}
body.has-topstatus .container{
  padding-top:76px;
}
/* Page Jouer: plein écran (mobile) */
body.play-page{
  max-width: 420px;
  margin: 0 auto;
}
body.play-page .container{
  max-width:none;
  margin:0;
  padding:76px 0 calc(96px + env(safe-area-inset-bottom)) 0;
}

/* Interface de jeu flottante */
.play-ui-floating{
  position: fixed !important;
  top: env(safe-area-inset-top) !important;
  left: env(safe-area-inset-left) !important;
  right: env(safe-area-inset-right) !important;
  bottom: env(safe-area-inset-bottom) !important;
  width: 100vw !important;
  height: 100dvh !important;
  /* Hauteur ajustée pour les safe areas */
  height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
  z-index: 20000 !important;
  background: var(--bg) !important;
  display: flex !important;
  flex-direction: column !important;
  opacity: 0 !important;
  transition: opacity 0.5s ease-in-out !important;
}
.play-ui-floating.visible{
  opacity: 1 !important;
}
.row{display:flex;gap:16px;flex-wrap:wrap}
.col{flex:1 1 320px}
.paper{
  background:rgba(26, 26, 46,.50);
  backdrop-filter: blur(10px);
  border:1px solid rgba(251, 191, 36,.25);
  border-radius:14px;
  padding:12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}
.card{
  background:rgba(26, 26, 46, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border:1px solid rgba(251, 191, 36, 0.3);
  border-radius:24px;
  padding:16px;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(251, 191, 36, 0.1) inset,
    0 0 40px rgba(251, 191, 36, 0.1);
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent, rgba(251, 191, 36, 0.05), transparent);
  animation: cardShine 6s linear infinite;
  pointer-events: none;
}
@keyframes cardShine {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
.appbar{
  display:flex;align-items:center;justify-content:space-between;gap:12px;
  margin:0 0 12px 0;
  position: sticky;
  top: 0;
  z-index: 20;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px 12px;
  border-radius: 18px;
  border: 1px solid rgba(251, 191, 36,.25);
  background: rgba(26, 26, 46,.70);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.brand{display:flex;align-items:center;gap:10px}
.brand img{width:34px;height:34px;flex:0 0 34px}
.brand .name{font-weight:700}
.title{display:flex;align-items:center;justify-content:space-between;gap:12px}
.title h1,.title h2,.title h3{margin:0}
.muted{color:var(--muted)}
.btn{
  display:inline-flex;align-items:center;justify-content:center;
  gap:8px;
  min-height:48px;
  padding:12px 14px;
  border-radius:14px;
  border:1px solid rgba(251, 191, 36,.2);
  background:rgba(26, 26, 46,.50);
  backdrop-filter: blur(10px);
  color:var(--text);
  cursor:pointer;
  text-decoration:none;
  user-select:none;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.2s ease;
}
.btn:hover {
  border-color: rgba(251, 191, 36,.35);
  background:rgba(26, 26, 46,.70);
  transform: translateY(-1px);
}
.btn.primary{
  background:linear-gradient(135deg, rgba(251, 191, 36, 0.3), rgba(245, 158, 11, 0.25));
  border-color:rgba(251, 191, 36, 0.5);
  color: #fbbf24;
  font-weight: 600;
  transition: all 0.3s ease;
}
.btn.primary:hover {
  background:linear-gradient(135deg, rgba(251, 191, 36, 0.4), rgba(245, 158, 11, 0.35));
  border-color:rgba(251, 191, 36, 0.6);
  box-shadow: 0 4px 20px rgba(251, 191, 36, 0.3);
  transform: translateY(-2px);
}
.btn.danger{border-color:rgba(251,113,133,.35);background:rgba(251,113,133,.12)}
.btn:disabled{opacity:.5;cursor:not-allowed}
.btn:active{transform: translateY(1px);}
.input{
  width:100%;
  padding:12px 14px;
  border-radius:14px;
  border:1px solid var(--border);
  background:rgba(0,0,0,.25);
  color:var(--text);
  outline:none;
}
.input:focus{
  border-color:rgba(251, 191, 36, 0.5);
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.1);
}
.stack{display:flex;flex-direction:column;gap:10px}
.msg{
  padding:10px 12px;
  border-radius:10px;
  border:1px solid rgba(251, 191, 36,.25);
  background:rgba(26, 26, 46,.50);
  backdrop-filter: blur(10px);
}
.msg.error{
  border-color:rgba(220, 38, 38,.45);
  background:rgba(220, 38, 38,.15);
  color:#ffd0d7
}
.msg.ok{
  border-color:rgba(52,211,153,.45);
  background:rgba(52,211,153,.15);
  color:#c8ffef
}
.pill{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:3px 10px;
  border-radius:999px;
  border:1px solid rgba(251, 191, 36,.25);
  background:rgba(26, 26, 46,.40);
  backdrop-filter: blur(5px);
  font-size:12px;
  color:var(--muted)
}
.hr{height:1px;background:var(--border);margin:12px 0}
.grid{display:grid;gap:10px}
.grid.two{grid-template-columns:repeat(2,minmax(0,1fr))}
.grid.three{grid-template-columns:repeat(3,minmax(0,1fr))}
/* Sur très petits écrans, forcer en colonne */
@media (max-width:360px){.grid.two,.grid.three{grid-template-columns:1fr}}

/* Animation shimmer pour la barre de progression */
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Tabbar bas (mobile game) - Collée au bas de l'écran visible (viewport) */
.tabbar{
  /* Positionnement fixe par rapport au viewport */
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  top: auto !important;
  width: 100vw !important;
  max-width: 100vw !important;
  z-index: 9999 !important;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom)) 12px;
  background: rgba(26, 26, 46,.75);
  border-top: 1px solid rgba(251, 191, 36,.2);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  margin: 0 !important;
  box-sizing: border-box;
  /* S'assurer qu'aucun parent n'interfère */
  transform: none !important;
  will-change: auto !important;
  /* Forcer le positionnement par rapport au viewport */
  contain: layout style paint;
}
.tabbar .inner{
  max-width:420px;
  margin:0 auto;
  display:grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap:8px;
  /* Centrer le contenu même si la tabbar prend toute la largeur */
  position: relative;
}
.navbtn{
  min-height:50px;
  border-radius:14px;
  border:1px solid rgba(251, 191, 36,.15);
  background: rgba(26, 26, 46,.40);
  color: var(--text);
  text-decoration:none;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:650;
  flex-direction: column;
  gap:2px;
  padding:6px 6px;
  transition: all 0.2s ease;
}
.navbtn:hover {
  border-color: rgba(251, 191, 36,.3);
  background: rgba(26, 26, 46,.60);
}
.nav-icon{
  font-size:20px;
  line-height:1;
  display:block;
}
.navbtn.active{
  border-color: rgba(251, 191, 36,.50);
  background: linear-gradient(135deg, rgba(251, 191, 36,.25), rgba(245, 158, 11,.20));
  color: #fbbf24;
}

/* Top status (lvl / credits) - Fixe en haut du viewport */
.topstatus{
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  top: 0 !important;
  width: 100% !important;
  z-index: 9998;
  padding: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(26, 26, 46,.70), rgba(22, 33, 62,.30));
  border-bottom: 1px solid rgba(251, 191, 36,.15);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  /* Positionnement par rapport au viewport, pas au body */
  transform: none !important;
}
.topstatus .inner{
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  display:flex;
  justify-content:space-between;
  gap:12px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px 12px;
  border-radius:0;
  border:none;
  background: transparent;
  box-shadow: none;
  pointer-events: auto;
  /* Centrer le contenu même si le topstatus prend toute la largeur */
  position: relative;
}
.topchip{
  display:flex;
  align-items:center;
  gap:10px;
  padding:8px 10px;
  border-radius:14px;
  border:1px solid rgba(251, 191, 36,.25);
  background: rgba(26, 26, 46,.50);
  backdrop-filter: blur(10px);
  min-width: 120px;
  justify-content:center;
}
.topchip svg{width:18px;height:18px;opacity:.95}
.topchip .val{font-weight:800;letter-spacing:.2px}
.topchip-content{
  display:flex;
  flex-direction:row;
  align-items:center;
  gap:4px;
}
.topchip-label{
  font-size:10px;
  color: var(--muted);
  font-weight:600;
  text-transform:uppercase;
  letter-spacing:0.5px;
  opacity:0.8;
}

/* Mini topstatus pour les pages sans hasTopStatus */
.topstatus-mini{
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  top: 0 !important;
  width: 100% !important;
  z-index: 9997;
  padding: 0;
  pointer-events: none;
  background: transparent;
  transform: none !important;
}
.topstatus-mini .inner{
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  display:flex;
  justify-content:flex-end;
  gap:8px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px 12px;
  pointer-events: auto;
  position: relative;
}
.topchip-mini{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:6px 8px;
  border-radius:10px;
  border:1px solid rgba(251, 191, 36,.2);
  background: rgba(26, 26, 46,.60);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 12px;
}
.topchip-mini .icon{
  font-size: 14px;
  line-height: 1;
  opacity: 0.9;
}
.topchip-mini .val{
  font-weight: 700;
  letter-spacing: 0.1px;
  font-size: 12px;
}
.topchip-mini-content{
  display:flex;
  flex-direction:row;
  align-items:center;
  gap:3px;
}
.topchip-mini-label{
  font-size:9px;
  color: var(--muted);
  font-weight:600;
  text-transform:uppercase;
  letter-spacing:0.3px;
  opacity:0.7;
  line-height:1;
}

/* Écran de chargement */
.loading-screen{
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 20001 !important;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.loading-screen.hidden{
  display: none !important;
}
.loading-container{
  background: rgba(26, 26, 46, 0.9) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
  border: 2px solid rgba(251, 191, 36, 0.3) !important;
  border-radius: 16px !important;
  padding: 32px !important;
  max-width: 400px !important;
  width: 90% !important;
  text-align: center !important;
}
.loading-header h2{
  color: var(--brand) !important;
  font-size: 24px !important;
  font-weight: 700 !important;
  margin: 0 0 24px 0 !important;
  text-shadow: 0 2px 10px rgba(251, 191, 36, 0.4) !important;
}
.loading-progress{
  margin-bottom: 16px !important;
}
.loading-bar-bg{
  width: 100% !important;
  height: 24px !important;
  background: rgba(15, 23, 42, 0.8) !important;
  border: 2px solid rgba(251, 191, 36, 0.3) !important;
  border-radius: 12px !important;
  overflow: hidden !important;
  margin-bottom: 12px !important;
}
.loading-bar-fill{
  height: 100% !important;
  background: linear-gradient(90deg, #fbbf24 0%, #f59e0b 100%) !important;
  /* width: 0% !important; */ /* Retiré pour permettre les mises à jour JS */
  /* transition: width 0.3s ease !important; */ /* Désactivé pour éviter les conflits avec JS */
  border-radius: 10px !important;
}
.loading-text{
  color: var(--text) !important;
  font-size: 18px !important;
  font-weight: 600 !important;
}
.loading-details{
  color: var(--muted) !important;
  font-size: 14px !important;
  font-style: italic !important;
}

/* Ranking / Classement */
.ranking-tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  padding: 4px 0;
  margin: -4px 0;
}
@media (max-width: 380px) {
  .ranking-tabs {
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
  }
}
.ranking-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 70px;
  -webkit-tap-highlight-color: transparent;
}
.ranking-tab:active {
  transform: scale(0.95);
}
.ranking-tab:hover {
  background: rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.2);
}
.ranking-tab.active {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.25) 0%, rgba(245, 158, 11, 0.2) 100%);
  border-color: var(--brand);
  color: var(--brand);
  box-shadow: 0 4px 12px rgba(251, 191, 36, 0.25);
}
.ranking-tab .tab-icon {
  font-size: 28px;
  line-height: 1;
  display: block;
}
.ranking-tab .tab-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  text-align: center;
  line-height: 1.2;
}
@media (max-width: 380px) {
  .ranking-tab {
    min-height: 65px;
    padding: 8px 6px;
    gap: 4px;
  }
  .ranking-tab .tab-icon {
    font-size: 24px;
  }
  .ranking-tab .tab-label {
    font-size: 9px;
  }
}

.ranking-loading,
.ranking-empty {
  padding: 40px 20px;
  text-align: center;
}

.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 0;
}

.ranking-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}
.ranking-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: transparent;
  transition: background 0.2s ease;
}
.ranking-item:hover {
  background: rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateX(2px);
}
.ranking-item.current-user {
  background: linear-gradient(90deg, rgba(251, 191, 36, 0.15) 0%, rgba(0, 0, 0, 0.2) 100%);
  border-color: rgba(251, 191, 36, 0.3);
}
.ranking-item.current-user::before {
  background: var(--brand);
}
.ranking-item.rank-1 {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.15) 0%, rgba(0, 0, 0, 0.2) 100%);
  border-color: rgba(255, 215, 0, 0.3);
  box-shadow: 0 4px 16px rgba(255, 215, 0, 0.1);
}
.ranking-item.rank-1::before {
  background: #ffd700;
}
.ranking-item.rank-2 {
  background: linear-gradient(135deg, rgba(192, 192, 192, 0.15) 0%, rgba(0, 0, 0, 0.2) 100%);
  border-color: rgba(192, 192, 192, 0.3);
  box-shadow: 0 4px 16px rgba(192, 192, 192, 0.1);
}
.ranking-item.rank-2::before {
  background: #c0c0c0;
}
.ranking-item.rank-3 {
  background: linear-gradient(135deg, rgba(205, 127, 50, 0.15) 0%, rgba(0, 0, 0, 0.2) 100%);
  border-color: rgba(205, 127, 50, 0.3);
  box-shadow: 0 4px 16px rgba(205, 127, 50, 0.1);
}
.ranking-item.rank-3::before {
  background: #cd7f32;
}

.ranking-rank {
  flex: 0 0 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
  min-width: 40px;
}
.ranking-rank .rank-number {
  font-size: 18px;
  color: var(--muted);
  font-weight: 700;
}

.ranking-user {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ranking-username {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ranking-extra {
  font-size: 12px;
  color: var(--muted);
}

.ranking-value {
  flex: 0 0 auto;
  text-align: right;
}
.ranking-value strong {
  font-size: 16px;
  font-weight: 700;
  color: var(--brand);
}

.ranking-user-info {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}


