/* Worms — habillage cartoon, lisible sur téléphone comme sur écran large */

:root {
  --fond: #16212d;
  --fond2: #22313f;
  --trait: #36495c;
  --texte: #f1f5f9;
  --dim: #94a7ba;
  --rouge: #ff4d4d;
  --bleu: #4da3ff;
  --or: #ffc43a;
  --vert: #5fd07a;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--fond);
  color: var(--texte);
  font-family: "Trebuchet MS", "Segoe UI", Roboto, system-ui, sans-serif;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#app { height: 100%; display: flex; align-items: center; justify-content: center; }

.hidden { display: none !important; }

button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }

.screen {
  width: 100%;
  max-width: 480px;
  max-height: 100%;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}

/* Centré tant que ça tient, défilable depuis le haut dès que ça déborde. */
.overlay {
  position: fixed;
  inset: 0;
  max-width: none;
  max-height: none;
  background: rgba(10, 16, 24, .93);
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
  overflow-y: auto;
  justify-content: flex-start;
  align-items: center;
  padding: 20px 16px 28px;
}
.overlay > :first-child { margin-top: auto; }
.overlay > :last-child { margin-bottom: auto; }

h1 {
  font-size: clamp(40px, 12vw, 72px);
  letter-spacing: 4px;
  color: #ffd84a;
  font-weight: 900;
  text-shadow: 0 4px 0 #b0561a, 0 8px 0 rgba(0, 0, 0, .35);
  transform: rotate(-2deg);
}
h2 { font-size: clamp(20px, 5vw, 28px); letter-spacing: 2px; }
.sous { color: var(--dim); letter-spacing: 1px; font-size: 14px; margin-bottom: 8px; }
.aide { color: var(--dim); font-size: 14px; line-height: 1.5; }
.version { color: var(--dim); opacity: .45; font-size: 11px; margin-top: 10px; }
.erreur { color: #ff8a7a; font-size: 14px; min-height: 18px; }

.actions { width: 100%; display: flex; flex-direction: column; gap: 10px; }

.bouton {
  width: 100%;
  padding: 14px 16px;
  background: var(--fond2);
  border: 2px solid var(--trait);
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .5px;
}
.bouton:active { background: var(--trait); transform: translateY(1px); }
.bouton.gros {
  background: linear-gradient(#ffd84a, #f0a41c);
  border-color: #b0561a;
  color: #2b1704;
  font-size: 18px;
  box-shadow: 0 4px 0 #b0561a;
}
.bouton.gros:active { box-shadow: 0 1px 0 #b0561a; transform: translateY(3px); }
.bouton.reprise { border-color: var(--vert); }
.bouton.discret { background: none; border-color: transparent; color: var(--dim); font-weight: 400; }

/* Réglages */
.groupe { width: 100%; text-align: left; }
.groupe > span { display: block; color: var(--dim); font-size: 13px; margin-bottom: 6px; letter-spacing: 1px; }
.choix { display: flex; gap: 6px; flex-wrap: wrap; }
.choix button {
  flex: 1 1 0;
  min-width: 56px;
  padding: 10px 6px;
  background: var(--fond2);
  border: 2px solid var(--trait);
  border-radius: 10px;
  font-weight: 700;
  font-size: 14px;
}
.choix button.on { border-color: var(--or); color: var(--or); background: #2b3340; }

.rejoindre { display: flex; gap: 8px; }
.rejoindre input {
  width: 38%;
  min-width: 110px;
  padding: 12px;
  text-align: center;
  font: inherit;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 6px;
  text-transform: uppercase;
  color: var(--texte);
  background: var(--fond2);
  border: 2px solid var(--trait);
  border-radius: 14px;
  user-select: text;
  -webkit-user-select: text;
}
.code-salle {
  font-size: clamp(40px, 14vw, 64px);
  font-weight: 900;
  letter-spacing: 10px;
  padding: 10px 14px 10px 24px;
  background: var(--fond2);
  border: 2px dashed var(--or);
  border-radius: 16px;
  color: var(--or);
  user-select: text;
  -webkit-user-select: text;
}

.aide-liste { width: 100%; max-width: 520px; text-align: left; font-size: 14px; line-height: 1.5; color: var(--dim); display: flex; flex-direction: column; gap: 6px; }
.aide-liste b { color: var(--texte); }
.aide-liste .arme { display: flex; gap: 10px; align-items: baseline; }
.aide-liste .arme .i { width: 26px; text-align: center; font-size: 18px; }

/* Jeu */
#jeu { position: fixed; inset: 0; }
#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

#hud {
  position: absolute; top: 8px; left: 8px; right: 8px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  pointer-events: none;
}
.equipe { flex: 1 1 0; max-width: 34%; min-width: 0; }
.equipe .nom { display: block; font-size: 12px; font-weight: 800; letter-spacing: 1px; text-shadow: 0 1px 3px #000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.equipe.e1 { text-align: right; }
.equipe.e0 .nom { color: #ff9a9a; }
.equipe.e1 .nom { color: #9ccbff; }
.barre { display: block; height: 12px; border-radius: 7px; background: rgba(0, 0, 0, .5); border: 2px solid rgba(255, 255, 255, .8); overflow: hidden; }
.barre b { display: block; height: 100%; width: 100%; transition: width .4s; }
.e0 .barre b { background: linear-gradient(#ff7a7a, #d62f2f); }
.e1 .barre b { background: linear-gradient(#7ab8ff, #2f78d6); margin-left: auto; }
.e0.actif .nom::before, .e1.actif .nom::after { content: " ▶"; }
.e1.actif .nom::before { content: "◀ "; }
.e1.actif .nom::after { content: ""; }

#centre { display: flex; flex-direction: column; align-items: center; gap: 4px; }
#chrono {
  min-width: 52px; padding: 2px 10px;
  text-align: center; font-size: 26px; font-weight: 900;
  background: rgba(0, 0, 0, .55); border: 3px solid #fff; border-radius: 12px;
  text-shadow: 0 2px 0 #000;
}
#chrono.urgent { color: #ff6a5a; border-color: #ff6a5a; }
#vent { display: flex; width: 100px; height: 10px; border-radius: 5px; background: rgba(0, 0, 0, .5); border: 2px solid rgba(255, 255, 255, .8); overflow: hidden; }
#vent span { flex: 1; position: relative; }
#vent i { position: absolute; top: 0; bottom: 0; background: #e8f4ff; width: 0; }
#vent .g i { right: 0; }
#vent .d i { left: 0; }

#outils { position: absolute; top: 62px; right: 8px; display: flex; flex-direction: column; gap: 6px; }
#outils button { width: 38px; height: 38px; border-radius: 10px; background: rgba(0, 0, 0, .5); border: 2px solid rgba(255, 255, 255, .6); font-size: 18px; }

#info {
  position: absolute; top: 76px; left: 50%; transform: translateX(-50%);
  max-width: 80%; text-align: center; font-weight: 800; font-size: 15px;
  text-shadow: 0 2px 4px #000, 0 0 8px #000; pointer-events: none;
}

#bas { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; }
#btn-arme {
  display: flex; align-items: center; gap: 10px; padding: 6px 16px 6px 10px;
  background: rgba(10, 16, 24, .75); border: 2px solid rgba(255, 255, 255, .7); border-radius: 14px;
}
#btn-arme #arme-ico { font-size: 28px; }
#btn-arme .t { display: flex; flex-direction: column; text-align: left; line-height: 1.15; }
#btn-arme b { font-size: 14px; }
#btn-arme small { color: var(--dim); font-size: 12px; }
#minut { display: flex; gap: 4px; }
#minut button { width: 34px; height: 34px; border-radius: 9px; background: rgba(0, 0, 0, .6); border: 2px solid rgba(255, 255, 255, .5); font-weight: 800; }
#minut button.on { border-color: var(--or); color: var(--or); }
#jauge { width: 180px; height: 10px; border-radius: 6px; background: rgba(0, 0, 0, .5); border: 2px solid rgba(255, 255, 255, .7); overflow: hidden; opacity: 0; }
#jauge.on { opacity: 1; }
#jauge i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #5fd07a, #ffd84a, #ff4d4d); }

#tactile { display: none; position: absolute; bottom: 8px; left: 8px; right: 8px; justify-content: space-between; align-items: flex-end; pointer-events: none; }
body.tactile #tactile { display: flex; }
body.tactile #bas { bottom: auto; top: 108px; left: auto; right: 8px; transform: none; align-items: flex-end; }
body.tactile #outils { top: 62px; }
#tactile > div { display: flex; gap: 8px; pointer-events: auto; }
#tactile .droite { flex-direction: column; align-items: flex-end; }
#tactile .milieu { flex-direction: column; }
#tactile button {
  width: 62px; height: 62px; border-radius: 50%;
  background: rgba(10, 16, 24, .6); border: 2px solid rgba(255, 255, 255, .6);
  font-size: 22px; font-weight: 800; touch-action: none;
}
#tactile button:active, #tactile button.presse { background: rgba(255, 216, 74, .5); }
#tactile .droite button { width: auto; min-width: 62px; padding: 0 14px; border-radius: 30px; font-size: 14px; height: 44px; }
#tactile #btn-tir { height: 62px; min-width: 96px; background: rgba(214, 47, 47, .75); font-size: 18px; }

#armes {
  position: absolute; inset: 0; background: rgba(10, 16, 24, .85); z-index: 20;
  display: flex; align-items: center; justify-content: center; padding: 10px; overflow-y: auto;
}
.grille { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; width: min(560px, 100%); }
.grille button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 2px; background: var(--fond2); border: 2px solid var(--trait); border-radius: 12px; min-width: 0;
}
.grille button .i { font-size: 26px; }
.grille button .n { font-size: 11px; font-weight: 700; line-height: 1.1; text-align: center; }
.grille button .m { font-size: 11px; color: var(--or); }
.grille button.vide { opacity: .35; }
.grille button.sel { border-color: var(--or); }
@media (max-width: 420px) { .grille { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

#toast {
  position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%);
  padding: 10px 20px; background: rgba(10, 16, 24, .8); border: 2px solid rgba(255, 255, 255, .7);
  border-radius: 14px; font-weight: 800; font-size: 18px; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .3s; max-width: 86%;
}
#toast.on { opacity: 1; }

/* Campagne */
.missions { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.mission {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; text-align: left;
  background: var(--fond2); border: 2px solid var(--trait); border-radius: 12px;
}
.mission:active:not(:disabled) { background: var(--trait); }
.mission .num { width: 34px; height: 34px; flex: none; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--or); color: #2b1704; font-weight: 900; }
.mission .tx { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.mission .tx small { color: var(--dim); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mission .etoiles { color: var(--or); letter-spacing: 2px; font-size: 16px; }
.mission.verrou { opacity: .45; }
.mission.verrou .num { background: var(--trait); color: var(--texte); }

#consigne {
  position: absolute; top: 100px; left: 50%; transform: translateX(-50%);
  max-width: 70%; text-align: center; font-size: 13px; font-weight: 700; padding: 4px 12px;
  background: rgba(10, 16, 24, .6); border-radius: 10px; pointer-events: none;
}
.objectif { color: var(--or); font-weight: 800; font-size: 18px; }
.consignes { text-align: left; max-width: 460px; color: var(--texte); font-size: 15px; line-height: 1.5; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
