/* ============================
   Base / Theme
============================ */
:root{
  --bg: #0b1020;
  --panel: rgba(255,255,255,.04);
  --panel2: rgba(255,255,255,.06);
  --text: #e9ecf6;
  --muted: rgba(233,236,246,.75);
  --border: rgba(255,255,255,.12);
  --shadow: 0 10px 28px rgba(0,0,0,.35);

  --green: rgba(61, 255, 170, .16);
  --green-b: rgba(61, 255, 170, .35);

  --orange: rgba(255, 195, 92, .16);
  --orange-b: rgba(255, 195, 92, .35);

  --red: rgba(255, 92, 92, .16);
  --red-b: rgba(255, 92, 92, .35);

  --radius: 18px;
  
  color-scheme: dark;
}

/* Support pour les systèmes en mode clair qui forcent le dark mode */
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: dark;
  }
}

*{ box-sizing: border-box; }
html, body{ height: 100%; }
body{
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  background: radial-gradient(1200px 600px at 20% -10%, rgba(120,140,255,.22), transparent 60%),
              radial-gradient(900px 500px at 90% 10%, rgba(255,160,92,.12), transparent 55%),
              var(--bg);
  color: var(--text);
  -webkit-text-fill-color: var(--text);
}

/* Force les couleurs de texte en mode sombre */
h1, h2, h3, h4, h5, h6, p, span, div, label {
  color: var(--text);
}

main{
  width: min(1100px, calc(100% - 24px));
  margin: 18px auto 30px;
  padding-bottom: 12px;
}

/* ============================
   Inputs / Buttons (fix lisibilité)
============================ */
input, select, button{
  font: inherit;
}

input, select{
  height: 42px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.06);
  color: var(--text);
  padding: 0 12px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

/* Force la couleur du texte dans les selects */
select option {
  background: #1a1a2e;
  color: var(--text);
}

input::placeholder{ color: rgba(233,236,246,.55); }

select{
  cursor: pointer;
}

button{
  height: 42px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.06);
  color: var(--text);
  padding: 0 12px;
  cursor: pointer;
  font-weight: 800;
}

button:hover{ background: rgba(255,255,255,.09); }
button:disabled{
  opacity: .55;
  cursor: not-allowed;
}

button.primary{
  background: rgba(120,140,255,.18);
  border-color: rgba(120,140,255,.35);
}

button.danger{
  background: rgba(255,92,92,.14);
  border-color: rgba(255,92,92,.35);
}

a{ color: #9bb5ff; }

/* ============================
   Header
============================ */
.top{
  width: min(1100px, calc(100% - 24px));
  margin: 18px auto 0;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: color-mix(in srgb, var(--bg) 85%, #000 15%);
  box-shadow: var(--shadow);
  padding: 16px 16px;
}

.top h1{
  margin: 0;
  font-size: 22px;
  letter-spacing: .2px;
}
.top .sub{
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.actions{
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
  flex-wrap: wrap;
}

.actions input{ flex: 1; min-width: 220px; }
.actions select{ min-width: 170px; }
.actions button{ white-space: nowrap; }

/* ============================
   Grid desktop
============================ */
.grid{
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

@media (max-width: 980px){
  .grid{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px){
  .grid{ grid-template-columns: 1fr; }
}

.armyBlock{
  margin: 18px 0 22px;
}
.armyTitle{
  margin: 0 0 10px;
  font-size: 15px;
  color: var(--muted);
  letter-spacing: .3px;
  font-weight: 900;
}

.card{
  border: 1px solid var(--border);
  background: rgba(255,255,255,.04);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.card img{
  width: 100%;
  height: 190px;
  object-fit: contain;
  background: rgba(255,255,255,.06);
  padding: 8px;
}

.card .p{
  padding: 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Bouton Ajouter plus gros */
.card button[data-add]{
  height: 52px;
  font-size: 16px;
  font-weight: 900;
  padding: 0 20px;
  background: rgba(120,140,255,.18);
  border-color: rgba(120,140,255,.35);
  flex-grow: 1;
}
.card button[data-add]:hover:not(:disabled){
  background: rgba(120,140,255,.28);
}

.row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
}

.price{
  font-weight: 900;
}

.tiny{
  font-size: 12px;
  color: var(--muted);
}

.badges{ display:flex; gap: 8px; flex-wrap: wrap; }
.badge{
  font-size: 12px;
  font-weight: 900;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.05);
}
.badge.green{ background: var(--green); border-color: var(--green-b); }
.badge.orange{ background: var(--orange); border-color: var(--orange-b); }
.badge.red{ background: var(--red); border-color: var(--red-b); }

/* ============================
   Dialogs (Panier / Annulation) - fix titres / labels illisibles
============================ */
.dlg{
  border: none;
  padding: 0;
  background: transparent;
}
.dlg::backdrop{
  background: rgba(0,0,0,.55);
}

.dlgInner{
  width: min(720px, 92vw);
  border-radius: 22px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, #000 12%);
  box-shadow: 0 30px 80px rgba(0,0,0,.55);
  padding: 14px;
}

.dlgHead{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  padding: 6px 6px 10px;
}
.dlgHead h2{
  margin: 0;
  font-size: 18px;
}
.x{
  width: 42px;
  padding: 0;
  display:flex;
  align-items:center;
  justify-content:center;
}

.basket{
  display:flex;
  flex-direction:column;
  gap: 10px;
  margin-top: 10px;
}

.basketItem{
  border: 1px solid var(--border);
  background: rgba(255,255,255,.04);
  border-radius: 16px;
  padding: 10px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
}

.checkout{
  margin-top: 12px;
  border-top: 1px solid rgba(255,255,255,.10);
  padding-top: 12px;
}

/* Total du panier */
.basketTotal{
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(120,140,255,.12);
  border: 1px solid rgba(120,140,255,.25);
  font-weight: 900;
  font-size: 18px;
}
.basketTotal span:last-child{
  font-size: 22px;
  color: #a8bcff;
}
.checkout label{
  display:block;
  font-weight: 900;
  font-size: 13px;
  margin-bottom: 8px;
}
.checkout input{ width: 100%; margin-top: 6px; }

.warning{
  margin: 10px 0;
  border: 1px solid rgba(255,195,92,.35);
  background: rgba(255,195,92,.10);
  border-radius: 16px;
  padding: 10px;
  font-size: 13px;
  line-height: 1.35;
}

/* ============================
   Ton CSS mobile (inchangé, juste conservé)
============================ */
/* Affichage auto des versions */
.top--mobile { display: none; }
.top--desktop { display: block; }

@media (max-width: 560px){
  .top--desktop{ display:none; }
  .top--mobile{ display:block; }
  main{ padding-bottom: 92px; } /* place pour bottom nav */
}

/* Header mobile compact */
.mTopRow{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.mTitle{ font-weight: 900; font-size: 18px; }
.mSub{ opacity:.8; font-size: 12px; margin-top: 2px; }
.mBasketBtn{
  border-radius: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.06);
  color: var(--text);
  font-weight: 900;
}
.mControls input{
  width: 100%;
  margin-bottom: 10px;
}
.mSelectRow{
  display:flex;
  gap: 8px;
}
.mSelectRow select{
  flex: 1;
}
.mManageBtn{
  width: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.06);
  color: var(--text);
  font-weight: 900;
}

/* Liste mobile par armée */
.mList{
  display:flex;
  flex-direction:column;
  gap: 10px;
}

/* Carte mobile */
.mCard{
  display:flex;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255,255,255,.04);
  padding: 10px;
  box-shadow: var(--shadow);
}
.mImg{
  width: 78px;
  height: 78px;
  border-radius: 14px;
  object-fit: contain;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  padding: 4px;
}
.mBody{ flex:1; min-width:0; display:flex; flex-direction:column; gap: 8px; }
.mTop{ display:flex; align-items:flex-start; justify-content:space-between; gap: 10px; }
.mName{
  font-weight: 900;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mPrice{ font-weight: 900; font-size: 14px; opacity:.95; }
.mMeta{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
}
.mRemain{ font-size: 12px; opacity:.8; }
.mActions{ display:flex; gap: 10px; align-items:center; justify-content:space-between; }
.mLink{
  font-size: 12px;
  text-decoration: none;
  color: #9bb5ff;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.04);
}
.mAdd{
  flex:1;
  font-weight: 900;
  border-radius: 12px;
  height: 48px;
  font-size: 15px;
  background: rgba(120,140,255,.18);
  border-color: rgba(120,140,255,.35);
}
.mAdd:hover:not(:disabled){
  background: rgba(120,140,255,.28);
}

/* Bottom nav (mobile) */
.bottomNav{
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  height: 64px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 85%, #000 15%);
  box-shadow: var(--shadow);
  display: none;
  gap: 8px;
  padding: 10px;
  z-index: 50;
}
@media (max-width: 560px){
  .bottomNav{ display:flex; }
}
.navBtn{
  flex: 1;
  height: 100%;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.06);
  color: var(--text);
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 8px;
  position: relative;
  font-weight: 800;
}
.navIco{ font-size: 18px; }
.navTxt{ font-size: 12px; opacity: .9; }
.navBadge{
  position:absolute;
  top: 6px;
  right: 8px;
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  padding: 0 7px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size: 12px;
  font-weight: 900;
  background: rgba(255,92,92,.18);
  border: 1px solid rgba(255,92,92,.35);
}

/* Toast XXL centré */
.toast{
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(.98);
  padding: 18px 20px;
  min-width: min(360px, 92vw);
  max-width: 92vw;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 82%, #000 18%);
  color: var(--text);
  box-shadow: var(--shadow);
  z-index: 9999;
  text-align: center;
  font-weight: 900;
  font-size: 16px;
  opacity: 0;
  transition: opacity .16s ease, transform .16s ease;
}
.toast.show{
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}