*{ box-sizing:border-box; }
html,body{ height:100%; margin:0; }

body{
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:#020617;
  color:#e5e7eb;
  overflow:hidden;
}

#app{
  height:100vh;   /* fallback */
  height:100dvh;  /* mobile bars */
  display:flex;
  flex-direction:column;
}

.stage{
  position:relative;
  flex:1 1 auto;
  display:flex;
  min-height:0;
}

#game{
  width:100%;
  height:100%;
  display:block;
}

/* ---------------- HUD overlay ----------------
   IMPORTANT : fixed + top très haut pour ne pas masquer le coin haut droit.
*/
.hudOverlay{
  position:fixed;
  top: calc(env(safe-area-inset-top, 0px) + 2px);
  left: calc(env(safe-area-inset-left, 0px) + 6px);
  right: calc(env(safe-area-inset-right, 0px) + 6px);
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:6px;
  z-index:5;
  pointer-events:none;
}

.hudMini{
  pointer-events:auto;
  background: rgba(0,0,0,.28);
  border:1px solid rgba(255,255,255,.12);
  border-radius:8px;
  padding:4px 6px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  max-width: 280px;
}

.hudMiniRight{
  max-width:none;
  width: min(520px, calc(100vw - 12px));
  padding:3px 6px;
}

.hudTitle{
  font-weight:900;
  font-size:10px;
  margin-bottom:2px;
  opacity: 0.9;
}

.hudLine{
  font-size:10px;
  line-height:1.2;
  opacity:.95;
  margin:1px 0;
  white-space:nowrap;
}

.hudLine .k{
  display:inline-block;
  min-width:42px;
  opacity:.78;
  font-size:9px;
}

.sep{
  display:inline-block;
  margin:0 4px;
  opacity:.6;
}

.mutedInline{
  opacity:.75;
  font-size:9px;
}

/* Ligne top du panneau droit : compacte */
.hudMiniRight .hudLineTop{
  display:flex;
  align-items:center;
  gap:6px;
  margin:0;
  font-size:9px;
}
.hudMiniRight .hudLineTop .k{ min-width:auto; }

/* Boutons (ligne unique) */
.hudButtons{
  margin-top:3px;
  display:flex;
  gap:4px;
  flex-wrap:wrap;
}

.hudMiniRight .hudButtonsTop{
  margin-top:3px;
  flex-wrap:nowrap; /* 1 ligne si possible */
}
@media (max-width: 920px){
  .hudMiniRight .hudButtonsTop{ flex-wrap:wrap; } /* wrap si écran étroit */
}

.btn{
  width:100%;
  padding:8px 8px;
  border-radius:8px;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color:#e5e7eb;
  font-weight:800;
  cursor:pointer;
  font-size:11px;
}
.btn:hover{ background: rgba(255,255,255,.09); }

.btn.primary{
  background: rgba(59,130,246,.35);
  border-color: rgba(59,130,246,.55);
}
.btn.primary:hover{ background: rgba(59,130,246,.45); }

.btn.small{
  width:auto;
  margin:0;
  padding:4px 6px;
  border-radius:6px;
  font-size:9px;
  font-weight:850;
  white-space:nowrap;
}

/* Pastille "Mode" */
.btn.pill{
  width:auto;
  padding:3px 7px;
  border-radius:999px;
  font-size:9px;
  font-weight:900;
  white-space:nowrap;
}

/* Responsive : empilement HUD si besoin */
@media (max-width: 820px){
  .hudOverlay{
    flex-direction:column;
    align-items:flex-start;
  }
  .hudMini, .hudMiniRight{
    max-width: 100%;
    width: 100%;
  }
}

/* ---------------- Mode 1 joueur ---------------- */
body.onePlayer #hudP1{ display:none; }
body.onePlayer #fieldPseudoR{ display:none; }

/* ---------------- Overlays ---------------- */
.overlay{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(0,0,0,.55);
  padding:18px;
  z-index:20;
}
.overlay.hidden{ display:none; }

.overlayCard{
  width:min(720px, 100%);
  background: #0b1224;
  border:1px solid rgba(255,255,255,.12);
  border-radius:16px;
  padding:16px 16px 14px;
  box-shadow: 0 18px 60px rgba(0,0,0,.45);
}

.overlayTitle{
  font-weight:900;
  font-size:18px;
  margin-bottom:8px;
}

.overlayText{
  font-size:14px;
  line-height:1.45;
  opacity:.95;
}

.overlayActions{
  margin-top:10px;
  display:flex;
  justify-content:flex-end;
  gap:10px;
}

/* Form pseudos */
.formGrid{
  margin-top:10px;
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:10px;
}
@media (max-width: 720px){
  .formGrid{ grid-template-columns: 1fr; }
}

.field label{
  display:block;
  font-size:12px;
  opacity:.85;
  margin-bottom:6px;
}

.field input{
  width:100%;
  padding:10px 10px;
  border-radius:10px;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color:#e5e7eb;
  outline:none;
  font-weight:800;
}
.field input:focus{
  border-color: rgba(59,130,246,.65);
  box-shadow: 0 0 0 3px rgba(59,130,246,.18);
}

.endSummary{
  margin-top:8px;
  padding:10px 12px;
  border:1px solid rgba(255,255,255,.10);
  border-radius:12px;
  background: rgba(255,255,255,.04);
  font-size:14px;
  line-height:1.5;
}

.muted{ opacity:.78; font-size:12px; }
