/* =====================================================================
   L'Échappée — styles propres au jeu (préfixe ec-)
   La barre, le plein écran et les infobulles sont dans css/games.css.
   ===================================================================== */

.ec-jeu {
  --mg-jeu-largeur: 1204px; /* barre de 1180 px + marges de 12 px : ne pas changer */
  --mgb-fond: linear-gradient(115deg, #10324a 0%, #17506f 60%, #2f7a5a 100%);
  --mgb-accent: #ffd447;
  --mgb-titre: linear-gradient(100deg, #ffffff, #ffd447);
  --mgb-police-titre: "Barlow Condensed", "Barlow", sans-serif;
  --mg-fs-fond: #eef2ee;
  --mg-bulle-fond: #10324a;
  --ec-police: "Barlow", system-ui, sans-serif;
  --ec-cond: "Barlow Condensed", "Barlow", sans-serif;
  --ec-encre: #17303f;
  --ec-doux: #5b6f7c;
  --ec-papier: #fbf8f0;
  --ec-filet: #dfe5dd;
  --ec-bleu: #17506f;
  --ec-jaune: #ffd447;
  --c: 104px; /* largeur d'une carte (posée par game.js) */
  --w: var(--c);
  --profil-h: 170px;
}

.ec-jeu [hidden] {
  display: none !important;
}

.ec-jeu .ec-stat-large {
  --mg-stat-largeur: 6.6em;
}

/* ---------- Zone ---------- */
.ec-zone {
  position: relative;
  box-sizing: border-box;
  align-self: center;
  width: min(var(--mg-barre-largeur, 1180px), calc(100vw - 24px));
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  font-family: var(--ec-police);
  color: var(--ec-encre);
  background: linear-gradient(180deg, #e6efe8, #f2efe4);
  user-select: none;
  -webkit-user-select: none;
}

.ec-jeu.mg-fs .ec-zone {
  align-self: stretch;
  width: auto;
  flex: 1;
  min-height: 0;
  border-radius: 0;
}

.ec-zone *,
.ec-zone *::before,
.ec-zone *::after {
  box-sizing: border-box;
}

.ec-lib {
  font-family: var(--ec-cond);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ec-doux);
  margin-bottom: 4px;
}

/* ---------- Profil de l'étape ---------- */
.ec-haut {
  flex: none;
  border-radius: 14px;
  background: var(--ec-papier);
  box-shadow:
    0 1px 0 #fff inset,
    0 2px 10px rgba(23, 48, 63, 0.08);
  padding: 8px 12px 6px;
}

.ec-titre-etape {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  font-family: var(--ec-cond);
  font-size: 19px;
  font-weight: 700;
  line-height: 1.1;
}

.ec-titre-etape small {
  font-size: 15px;
  font-weight: 600;
  color: var(--ec-doux);
}

.ec-badge-type {
  font-size: 13px;
  padding: 2px 9px;
  border-radius: 999px;
  color: #fff;
  background: var(--ec-bleu);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ec-profil {
  position: relative;
  height: var(--profil-h);
  margin-top: 4px;
}

.ec-profil svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.ec-profil text {
  font-family: var(--ec-cond);
}

/* Grande annonce au-dessus du profil (sprint, sommet, arrivée, contrôle) */
.ec-haut {
  position: relative;
}

.ec-annonce {
  --coul: #ffd447;
  position: absolute;
  left: 50%;
  top: 44px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 40px);
  padding: 10px 22px 10px 16px;
  border-radius: 14px;
  background: #17303f;
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: inset 6px 0 0 var(--coul), 0 10px 30px rgba(23, 48, 63, 0.35);
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -12px) scale(0.96);
  transition: opacity 0.3s, transform 0.3s;
}

.ec-annonce.ec-visible {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.ec-annonce b {
  font-family: var(--ec-cond);
  font-size: 15px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 9px;
  border-radius: 6px;
  background: var(--coul);
  color: #15171a;
}

/* Zones d'infobulle sur les repères du profil */
.ec-repere {
  position: absolute;
  z-index: 1;
  width: 28px;
  height: 48px;
  cursor: help;
}

/* Coureurs posés sur le profil */
.ec-pion {
  position: absolute;
  z-index: 2;
  width: 24px;
  height: 24px;
  margin: -24px 0 0 -12px;
  transition:
    left 0.9s cubic-bezier(0.45, 0.05, 0.3, 1),
    top 0.9s cubic-bezier(0.45, 0.05, 0.3, 1);
}

.ec-pion svg {
  position: static;
  width: 24px;
  height: 24px;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.35));
}

.ec-pion.ec-actif svg {
  filter: drop-shadow(0 0 5px var(--coul))
    drop-shadow(0 2px 2px rgba(0, 0, 0, 0.35));
  animation: ec-sautille 0.8s infinite;
}

@keyframes ec-sautille {
  50% {
    transform: translateY(-3px);
  }
}

.ec-pion-inutilise {
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translateX(-50%);
  font-family: var(--ec-cond);
  font-size: 12px;
  line-height: 1;
  padding: 1px 5px;
  border-radius: 6px;
  background: var(--coul);
  color: #15171a;
  white-space: nowrap;
}

.ec-pion.ec-fini {
  opacity: 0.6;
}

/* ---------- Coureurs ---------- */
.ec-milieu {
  flex: none;
  height: 92px; /* hauteur fixe : le reste de l'écran est calculé d'après elle */
  display: flex;
  gap: 10px;
  min-height: 0;
}

.ec-coureurs {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 8px;
}

.ec-coureur {
  --coul: #999;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 7px 10px 8px;
  border-radius: 12px;
  background: #fff;
  box-shadow:
    inset 4px 0 0 var(--coul),
    0 2px 8px rgba(23, 48, 63, 0.08);
  transition:
    box-shadow 0.2s,
    background 0.2s;
}

.ec-coureur.ec-tour {
  background: #fffbe8;
  box-shadow:
    inset 4px 0 0 var(--coul),
    0 0 0 2px var(--coul),
    0 4px 14px rgba(23, 48, 63, 0.15);
}

.ec-coureur.ec-cible {
  cursor: pointer;
  background: #fff3c4;
  box-shadow:
    inset 4px 0 0 var(--coul),
    0 0 0 3px #e0a800,
    0 0 16px rgba(224, 168, 0, 0.45);
  animation: ec-pulse 1s infinite;
}

@keyframes ec-pulse {
  50% {
    box-shadow:
      inset 4px 0 0 var(--coul),
      0 0 0 3px #e0a800,
      0 0 3px rgba(224, 168, 0, 0.2);
  }
}

.ec-c-tete {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.ec-c-tete svg {
  width: 22px;
  height: 22px;
  flex: none;
}

.ec-c-nom {
  font-family: var(--ec-cond);
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
}

.ec-c-pos {
  margin-left: auto;
  font-family: var(--ec-cond);
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
}

.ec-c-pos small {
  font-weight: 600;
  color: var(--ec-doux);
}

.ec-jauge {
  display: flex;
  gap: 2px;
  height: 9px;
}

.ec-jauge i {
  flex: 1;
  border-radius: 2px;
  background: #e3e8e4;
}

.ec-jauge i.ec-plein {
  background: linear-gradient(#5fd08a, #2c9c5c);
}

/* Adversaires : énergie seulement devinée */
.ec-jauge-floue {
  align-items: center;
  height: 12px;
}

.ec-jauge-floue i {
  flex: 0 0 22px;
  height: 9px;
}

.ec-jauge-floue span {
  margin-left: 6px;
  font-size: 12px;
  font-weight: 700;
  font-style: italic;
  color: var(--ec-doux);
}

.ec-jauge.ec-jauge-basse i.ec-plein {
  background: linear-gradient(#ffb15c, #e07b16);
}

.ec-jauge.ec-jauge-vide i.ec-plein {
  background: linear-gradient(#ff7a6b, #d33b2c);
}

.ec-coureur {
  overflow: hidden;
}

.ec-c-ligne {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ec-doux);
  min-height: 20px;
  flex-wrap: nowrap;
  overflow: hidden;
}

.ec-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #eef2ef;
  color: var(--ec-encre);
  white-space: nowrap;
}

.ec-tag.ec-mal {
  background: #ffe1dc;
  color: #b0281b;
}

.ec-tag.ec-bien {
  background: #dcf3e4;
  color: #1d7a45;
}

.ec-tag.ec-suspect {
  background: #efe1ff;
  color: #6a2fb0;
}

.ec-tag svg {
  width: 14px;
  height: 14px;
}

/* ---------- Radio course ---------- */
.ec-journal-bloc {
  position: relative;
  flex: 0 0 260px;
}

.ec-journal {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 6px 10px;
  list-style: none;
  overflow-y: auto;
  border-radius: 12px;
  background: #17303f;
  color: #d7e3ea;
  font-size: 12.5px;
  line-height: 1.3;
  scrollbar-width: thin;
}

.ec-journal li {
  padding: 3px 0 3px 8px;
  border-left: 3px solid var(--coul, #5b6f7c);
  margin-bottom: 3px;
}

.ec-journal li:first-child {
  color: #fff;
  font-weight: 600;
}

.ec-journal li.ec-fort {
  color: var(--ec-jaune);
}

/* ---------- Commandes ---------- */
.ec-bas {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ec-message {
  flex: none;
  height: 36px; /* hauteur fixe : afficher des boutons ne décale rien */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  font-weight: 600;
  font-size: 15px;
  text-align: center;
}

.ec-message .btn-vert,
.ec-message .btn-bleu,
.ec-message .btn-rouge {
  height: 30px;
  margin: 0;
  display: inline-flex;
  align-items: center;
  line-height: 1;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
  padding: 0 14px;
  font-size: 14px;
  font-family: var(--ec-police);
}

.ec-commandes {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  justify-content: center;
}

.ec-main-bloc {
  flex: 0 1 auto;
  min-width: 0;
}

.ec-main {
  display: flex;
  gap: 8px;
  min-height: calc(var(--c) * 1.4);
}

.ec-efforts-bloc {
  flex: 0 0 380px;
}

.ec-efforts {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ---------- Cartes ---------- */
.ec-carte {
  position: relative;
  flex: none;
  width: var(--w);
  height: calc(var(--w) * 1.4);
  border-radius: calc(var(--w) * 0.09);
  background: #fff;
  padding: calc(var(--w) * 0.045);
  box-shadow: 0 2px 6px rgba(23, 48, 63, 0.25);
  cursor: pointer;
  transition:
    transform 0.15s,
    box-shadow 0.15s,
    filter 0.15s;
}

.ec-carte:hover {
  transform: translateY(-5px);
}

.ec-carte.ec-choisie {
  transform: translateY(-10px);
  box-shadow:
    0 0 0 3px #e0a800,
    0 10px 20px rgba(23, 48, 63, 0.3);
}

.ec-carte.ec-injouable {
  filter: saturate(0.3) brightness(0.92);
}

/* carte prévue pour la manche */
.ec-carte.ec-prevue,
.ec-carte.ec-a-defausser {
  transform: translateY(-10px);
  box-shadow: 0 0 0 3px #1d7a45, 0 10px 20px rgba(23, 48, 63, 0.3);
}
.ec-carte.ec-a-defausser {
  box-shadow: 0 0 0 3px #b0281b, 0 10px 20px rgba(23, 48, 63, 0.3);
  filter: grayscale(0.6);
}
.ec-carte.ec-prevue::after,
.ec-carte.ec-a-defausser::after {
  content: "Prévue";
  position: absolute;
  bottom: -9px;
  left: 50%;
  transform: translateX(-50%);
  padding: 1px 9px;
  border-radius: 999px;
  background: #1d7a45;
  color: #fff;
  font: 700 12px var(--ec-cond);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}
.ec-carte.ec-a-defausser::after {
  content: "Défaussée";
  background: #b0281b;
}

.ec-effort-km.ec-flou {
  font-family: var(--ec-police);
  font-size: 13px;
  font-weight: 600;
  color: var(--ec-doux);
}

.ec-tag.ec-dernier {
  background: #17303f;
  color: #fff;
}
.ec-tag.ec-dernier.ec-bien {
  background: #1d7a45;
  color: #fff;
}

.ec-main.ec-attente .ec-carte {
  cursor: default;
}

.ec-main.ec-attente .ec-carte:hover {
  transform: none;
}

.ec-carte-fond {
  position: absolute;
  inset: calc(var(--w) * 0.045);
  border-radius: calc(var(--w) * 0.06);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(var(--w) * 0.05) calc(var(--w) * 0.05) calc(var(--w) * 0.04);
  overflow: hidden;
  background: var(--fond);
  color: #fff;
}

.ec-sort {
  --fond: linear-gradient(160deg, #e9573f, #b3271a);
}
.ec-controle {
  --fond: linear-gradient(160deg, #8e5ad6, #5a2c9e);
}
.ec-ravito {
  --fond: linear-gradient(160deg, #3fb877, #1e7d48);
}
.ec-depannage {
  --fond: linear-gradient(160deg, #f0a43a, #c46d0c);
}
.ec-materiel {
  --fond: linear-gradient(160deg, #3a8ed6, #1d5a96);
}

.ec-carte-nom {
  font-family: var(--ec-cond);
  font-weight: 700;
  font-size: calc(var(--w) * 0.15);
  line-height: 1;
  text-align: center;
  min-height: 2em;
  display: flex;
  align-items: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.ec-carte svg {
  width: 70%;
  height: auto;
  flex: none;
  margin: 2px 0;
}

.ec-carte-txt {
  margin-top: auto;
  font-size: calc(var(--w) * 0.088);
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
  opacity: 0.95;
}

/* ---------- Boutons d'effort ---------- */
.ec-effort {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0;
  padding: 0 12px;
  height: calc((var(--c) * 1.4 - 20px) / 6);
  min-height: 30px;
  border: 0;
  border-radius: 10px;
  background: #fff;
  color: var(--ec-encre);
  font: 600 14px var(--ec-police);
  text-align: left;
  cursor: pointer;
  box-shadow:
    inset 0 0 0 1px var(--ec-filet),
    0 1px 3px rgba(23, 48, 63, 0.08);
  transition:
    background 0.15s,
    box-shadow 0.15s,
    transform 0.1s;
}

.ec-effort:hover:not(:disabled) {
  background: #fff7d6;
  box-shadow: inset 0 0 0 2px #e0a800;
}

.ec-effort:active:not(:disabled) {
  transform: scale(0.98);
}

.ec-effort:disabled {
  cursor: default;
  opacity: 0.45;
}

.ec-effort:focus-visible {
  outline: 3px solid #e0a800;
}

.ec-effort b {
  font-family: var(--ec-cond);
  font-size: 18px;
  color: var(--ec-encre);
}

.ec-effort-tag {
  font-size: 12px;
  font-weight: 700;
  color: var(--ec-doux);
  white-space: nowrap;
}

.ec-effort-tag.ec-bien {
  color: #1d7a45;
}

.ec-effort-tag.ec-mal {
  color: #b0281b;
}

.ec-effort-km {
  font-family: var(--ec-cond);
  font-size: 18px;
  font-weight: 700;
  min-width: 62px;
  text-align: right;
}

.ec-effort-cout {
  font-family: var(--ec-cond);
  font-size: 16px;
  font-weight: 700;
  min-width: 44px;
  text-align: right;
  color: #c0461a;
}

.ec-effort-cout.ec-gain {
  color: #1d7a45;
}

.ec-effort.ec-attendre {
  grid-template-columns: 1fr;
  height: auto;
  padding: 14px;
  text-align: center;
  background: #fff3c4;
}

/* ---------- Fenêtres ---------- */
.ec-voile {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(16, 50, 74, 0.55);
  backdrop-filter: blur(3px);
}

.ec-fen {
  width: min(560px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 18px 24px;
  border-radius: 18px;
  background: var(--ec-papier);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.4);
  text-align: center;
}

.ec-fen-large {
  width: min(820px, 100%);
}

.ec-fen-titre {
  margin: 0;
  font-family: var(--ec-cond);
  font-size: 38px;
  font-weight: 700;
  color: var(--ec-bleu);
}

.ec-fen-texte {
  margin: 2px 0 12px;
  font-size: 15px;
  color: var(--ec-doux);
}

.ec-choix-groupe {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 10px;
}

.ec-choix-lib {
  font-family: var(--ec-cond);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ec-doux);
}

.ec-choix {
  display: flex;
  gap: 5px;
  padding: 4px;
  border-radius: 12px;
  background: #e8ece4;
}

.ec-choix button {
  flex: 1;
  margin: 0;
  padding: 8px 4px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  font: 600 15px var(--ec-police);
  color: var(--ec-encre);
  cursor: pointer;
}

/* survol : seulement les choix non retenus (le choix retenu garde son fond bleu) */
.ec-choix button:not(.ec-oui):not(:disabled):hover {
  background: rgba(255, 255, 255, 0.7);
  color: var(--ec-encre);
}

.ec-choix button.ec-oui {
  background: var(--ec-bleu);
  color: #fff;
  box-shadow: 0 2px 6px rgba(23, 80, 111, 0.35);
}

.ec-choix button:disabled {
  opacity: 0.4;
  cursor: default;
}

.ec-choix button:focus-visible {
  outline: 3px solid #e0a800;
}

#ec-reglages-fen .ec-fen-titre {
  margin-bottom: 12px;
}

.ec-options .mg-option {
  color: var(--ec-encre);
}

.ec-options {
  display: flex;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
  padding: 6px 4px;
  color: var(--ec-encre);
}

/* Interrupteurs du site aux couleurs du jeu */
.ec-jeu input[type="checkbox"] {
  background: #d5dcd3;
  border-color: #b9c4b8;
}
.ec-jeu input[type="checkbox"]:checked {
  background: var(--ec-bleu);
  border-color: var(--ec-bleu);
}
.ec-jeu input[type="checkbox"]:hover:not(:disabled) {
  box-shadow: 0 0 0 4px rgba(23, 80, 111, 0.15);
}
.ec-jeu input[type="checkbox"]:focus-visible {
  outline-color: #e0a800;
}

.ec-fen-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.ec-fen-actions button {
  min-width: 150px;
  font-family: var(--ec-police);
  font-size: 16px;
}

.ec-bilan-contenu {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  text-align: left;
}

.ec-classement h3 {
  margin: 0 0 4px;
  font-family: var(--ec-cond);
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ec-classement h3 svg {
  width: 22px;
  height: 22px;
}

.ec-classement table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.ec-classement td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--ec-filet);
  white-space: nowrap;
}

.ec-classement td:first-child {
  width: 1.8em;
  font-weight: 700;
  color: var(--ec-doux);
}

.ec-classement td:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.ec-classement tr.ec-moi td {
  background: #fff3c4;
}

.ec-pastille {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--coul);
  vertical-align: 0;
}

/* ---------- Boutons des fenêtres aux couleurs du jeu ---------- */
.ec-jeu .btn-vert {
  background: var(--ec-jaune);
  border-color: #e0a800;
  color: var(--ec-encre);
  box-shadow: 0 4px 0 #b88a00;
}
.ec-jeu .btn-vert:hover {
  background: #ffdd6b;
  border-color: #e0a800;
  color: var(--ec-encre);
  box-shadow:
    0 4px 0 #b88a00,
    0 0 0 4px rgba(255, 212, 71, 0.35);
}
.ec-jeu .btn-bleu {
  background: var(--ec-bleu);
  border-color: #0f3a52;
  color: #fff;
  box-shadow: 0 4px 0 #0b2a3c;
}
.ec-jeu .btn-bleu:hover {
  background: #1d6189;
  border-color: #0f3a52;
  color: #fff;
  box-shadow:
    0 4px 0 #0b2a3c,
    0 0 0 4px rgba(23, 80, 111, 0.25);
}
.ec-jeu .btn-rouge {
  background: transparent;
  border-color: #b0281b;
  color: #b0281b;
  box-shadow: none;
}
.ec-jeu .btn-rouge:hover {
  background: rgba(176, 40, 27, 0.08);
  border-color: #b0281b;
  color: #b0281b;
  box-shadow: none;
}
.ec-jeu .btn-vert:focus-visible,
.ec-jeu .btn-bleu:focus-visible,
.ec-jeu .btn-rouge:focus-visible {
  outline-color: #e0a800;
}

/* ---------- Petits écrans ---------- */
@media (max-width: 900px) {
  .ec-milieu,
  .ec-commandes {
    flex-direction: column;
    align-items: stretch;
  }
  .ec-coureurs {
    flex-wrap: wrap;
  }
  .ec-coureur {
    flex: 1 1 45%;
  }
  .ec-journal-bloc {
    flex: none;
    height: 110px;
  }
  .ec-efforts-bloc {
    flex: none;
  }
  .ec-main {
    flex-wrap: wrap;
  }
}
