/* ===============================
   Melting Arrows – styles spécifiques
   =============================== */

.ma-jeu {
  --ma-violet: #7c5cff;
  --ma-violet-clair: #a891ff;
  --ma-cyan: #5affe1;
  --ma-rouge: #ff5470;
  --ma-vert: #4ade80;
  --ma-encre: #0b0e22;
  --ma-panneau: #151a33;
  --ma-ligne: rgba(255, 255, 255, 0.09);
  --ma-texte: #e8e9ff;
  --ma-texte-doux: #9aa0c8;
  /* Barre commune (css/games.css) aux couleurs du jeu */
  --mg-jeu-largeur: 1100px;
  --mgb-fond: linear-gradient(120deg, #1b1f3f, #2a1f55);
  --mgb-texte: var(--ma-texte);
  --mgb-doux: var(--ma-texte-doux);
  --mgb-accent: var(--ma-cyan);
  --mgb-titre: var(--mg-degrade, linear-gradient(100deg, #ffb547, #ff4f9a 45%, #a891ff));
  --mgb-ombre: 0 4px 18px rgba(30, 20, 80, 0.25);
  --mg-fs-fond: #080a1a;
  --mg-bulle-fond: var(--ma-panneau);
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- Bandeau : titre et statistiques ---------- */

.ma-stats {
  flex: 1;
  display: flex;
  align-items: flex-start; /* libellés alignés en haut, même sous Flèches (barre de progression) */
  gap: 26px;
  min-width: 0;
}

.ma-stat-fleches .mg-stat-val small {
  margin-left: 2px;
  font-size: 0.9em;
  font-weight: 500;
  color: var(--ma-texte-doux);
  font-variant-numeric: tabular-nums;
}

.ma-stat-accidents b {
  color: #ff8a9c;
}

/* Barre de progression sous le nombre de flèches */
.ma-progres {
  display: block;
  width: 100%;
  min-width: 78px;
  height: 4px;
  margin-top: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.ma-progres span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--ma-violet), var(--ma-cyan));
  transition: width 0.35s ease;
}

/* ---------- Boutons ---------- */

.ma-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ma-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 16px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--ma-violet), #5f3ff0);
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 0.95em;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(95, 63, 240, 0.3);
  transition:
    transform 0.1s,
    box-shadow 0.15s,
    filter 0.15s,
    opacity 0.15s;
}

.ma-btn:hover:not(:disabled) {
  filter: brightness(1.1);
  box-shadow: 0 6px 18px rgba(95, 63, 240, 0.4);
}

.ma-btn:active:not(:disabled) {
  transform: scale(0.96);
}

.ma-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.ma-btn.clair {
  background: #f0edff;
  color: var(--ma-violet);
  box-shadow: none;
}

.ma-btn.clair:hover {
  background: #e4dfff;
}

.ma-btn-aide {
  background: linear-gradient(135deg, #22c55e, #15924a);
  box-shadow: 0 4px 12px rgba(21, 146, 74, 0.28);
}

.ma-btn-aide:hover:not(:disabled) {
  box-shadow: 0 6px 18px rgba(21, 146, 74, 0.38);
}

/* Coût de l'aide, en pastille */
.ma-cout {
  padding: 1px 7px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.22);
  font-size: 0.8em;
  font-variant-numeric: tabular-nums;
}

.ma-btn:focus-visible,
.ma-niveau:focus-visible {
  outline: 3px solid var(--ma-violet-clair);
  outline-offset: 2px;
}

/* ---------- Commandes ---------- */

/* Choix de la taille : boutons collés en pilule */
.ma-niveaux {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: #f0edff;
}

.ma-niveau {
  height: 32px;
  padding: 0 14px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #5b5880;
  font: inherit;
  font-weight: 600;
  font-size: 0.9em;
  cursor: pointer;
  transition:
    background 0.2s,
    color 0.2s,
    box-shadow 0.2s;
}

.ma-niveau:hover {
  color: var(--ma-violet);
}

.ma-niveau.actif {
  background: #fff;
  color: var(--ma-violet);
  box-shadow: 0 2px 8px rgba(80, 60, 200, 0.18);
}

/* Numéro de la grille, dans le bandeau à côté du lien */
.ma-grille-num {
  align-self: center;
  margin-right: 4px;
  padding: 4px 10px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ma-texte-doux);
  font-size: 0.85em;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- Plateau ---------- */

.ma-scene {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.ma-canvas {
  display: block;
  border-radius: 18px;
  background: var(--ma-encre);
  box-shadow:
    0 2px 6px rgba(23, 20, 46, 0.12),
    0 24px 50px -22px rgba(23, 20, 46, 0.55);
  touch-action: manipulation;
}

/* Messages éphémères, en haut du plateau */
.ma-toasts {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  z-index: 5;
}

.ma-toast {
  padding: 8px 16px;
  border-radius: 99px;
  background: rgba(27, 22, 64, 0.92);
  color: #fff;
  font-size: 0.9em;
  font-weight: 500;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  animation: ma-toast-entree 0.25s ease;
  transition:
    opacity 0.35s,
    transform 0.35s;
}

.ma-toast.sort {
  opacity: 0;
  transform: translateY(-6px);
}

@keyframes ma-toast-entree {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* ---------- Fenêtres ---------- */

.ma-modal {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(11, 14, 34, 0.55);
  backdrop-filter: blur(4px);
  animation: ma-fondu 0.2s ease;
}

.ma-modal[hidden] {
  display: none;
}

@keyframes ma-fondu {
  from {
    opacity: 0;
  }
}

.ma-modal-box {
  width: min(540px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  box-sizing: border-box;
  padding: 26px 28px 22px;
  border-radius: 22px;
  background: #fff;
  color: var(--mg-texte, #25233d);
  box-shadow: 0 30px 70px -20px rgba(11, 14, 34, 0.6);
  animation: ma-apparition 0.35s var(--mg-ressort, cubic-bezier(0.34, 1.56, 0.64, 1));
  user-select: text;
  -webkit-user-select: text;
}

@keyframes ma-apparition {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(12px);
  }
}

.ma-modal-titre {
  font-family: "Madimi One", sans-serif;
  font-size: 1.9em;
  line-height: 1.1;
  background: var(--mg-degrade, linear-gradient(100deg, #ffb547, #ff4f9a 45%, #7c5cff));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.ma-modal-sous {
  margin: 4px 0 14px;
  color: var(--mg-doux, #6c6a88);
  font-weight: 500;
}

.ma-modal-box p {
  margin: 12px 0;
  line-height: 1.5;
}

.ma-regles {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ma-regle {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  line-height: 1.45;
}

.ma-regle b {
  display: block;
  margin-bottom: 1px;
}

/* Petites vignettes : une flèche qui sort, une qui percute, une aidée */
.ma-regle-ico {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--ma-encre) center / 34px 34px no-repeat;
}

.ma-regle-ico.sortie {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 34 34' fill='none' stroke='%23dfe3ff' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 27V17h12V8'/%3E%3Cpath d='M14 10l4-5 4 5z' fill='%23dfe3ff'/%3E%3C/svg%3E");
}

.ma-regle-ico.choc {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 34 34' fill='none' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 26h8V17h7' stroke='%23ff5470'/%3E%3Cpath d='M19 13l5 4-5 4z' fill='%23ff5470' stroke='%23ff5470'/%3E%3Cpath d='M29 6v22' stroke='%23dfe3ff'/%3E%3C/svg%3E");
}

.ma-regle-ico.aide {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 34 34' fill='none' stroke='%234ade80' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 9h10v14h9'/%3E%3Cpath d='M23 19l5 4-5 4z' fill='%234ade80'/%3E%3C/svg%3E");
}

.ma-raccourcis {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 6px;
  font-size: 0.88em;
  color: var(--mg-doux, #6c6a88);
}

.ma-raccourcis kbd {
  display: inline-block;
  min-width: 1.4em;
  padding: 1px 6px;
  border-radius: 6px;
  border: 1px solid rgba(35, 33, 61, 0.15);
  border-bottom-width: 2px;
  background: #f7f6fd;
  color: #3d3a5c;
  font: inherit;
  font-weight: 700;
  text-align: center;
}

.ma-modal-btns {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

/* Confirmation */
.ma-confirm {
  width: min(500px, 100%);
}

.ma-confirm .ma-modal-btns {
  flex-wrap: nowrap;
}

/* Trop étroit pour deux boutons côte à côte : l'un sous l'autre, pleine largeur */
@media (max-width: 520px) {
  .ma-confirm .ma-modal-btns {
    flex-direction: column-reverse;
  }

  .ma-confirm .ma-modal-btns .ma-btn {
    justify-content: center;
  }
}

.ma-confirm .ma-modal-titre {
  font-size: 1.6em;
}

.ma-confirm p {
  color: var(--mg-doux, #6c6a88);
}

/* Victoire */
.ma-victoire {
  text-align: center;
}

.ma-victoire .ma-modal-btns {
  justify-content: center;
}

.ma-etoiles {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 2.6em;
  line-height: 1;
}

.ma-etoiles span {
  color: #e4e1f3;
}

.ma-etoiles span.on {
  color: #ffc23d;
  text-shadow: 0 4px 14px rgba(255, 170, 30, 0.45);
  animation: ma-etoile 0.5s var(--mg-ressort, cubic-bezier(0.34, 1.56, 0.64, 1)) both;
  animation-delay: calc(0.25s + var(--i) * 0.15s);
}

@keyframes ma-etoile {
  from {
    opacity: 0;
    transform: scale(0.2) rotate(-40deg);
  }
}

.ma-v-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 6px;
}

.ma-v-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 6px;
  border-radius: 14px;
  background: #f4f3fb;
}

.ma-v-stat span {
  font-size: 0.72em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--mg-doux, #6c6a88);
}

.ma-v-stat b {
  font-size: 1.45em;
  font-variant-numeric: tabular-nums;
  color: var(--mg-encre, #17142e);
}

.ma-v-stat small {
  font-size: 0.8em;
  color: var(--mg-doux, #6c6a88);
  font-variant-numeric: tabular-nums;
}

.ma-v-stat em {
  font-style: normal;
  font-weight: 700;
  color: #e0447a;
}

/* ---------- Infobulle (attribut data-bulle) ---------- */

/* ---------- Plein écran ---------- */

/* Plein écran commun (css/games.css) : commandes dans les tons du jeu */
.ma-jeu.mg-fs {
  --mgc-fond: var(--ma-panneau);
  --mgc-bord: var(--ma-ligne);
  --mgc-texte: var(--ma-texte-doux);
}

.ma-jeu.mg-fs > * {
  flex-shrink: 0;
}

.ma-jeu.mg-fs .ma-scene {
  flex: 1 1 auto;
  height: auto;
  min-height: 200px;
}

.ma-jeu.mg-fs .ma-niveaux {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ma-texte-doux);
}

.ma-jeu.mg-fs .ma-niveau {
  color: var(--ma-texte-doux);
}

.ma-jeu.mg-fs .ma-niveau.actif {
  background: var(--ma-violet);
  color: #fff;
}

.ma-jeu.mg-fs .ma-canvas {
  box-shadow: none;
}

/* Le pied de page du site est fixe : inutile de garder 60 px de vide sous le jeu */
body:has(#ma-jeu) {
  padding-bottom: 34px;
}

/* ---------- Petits écrans ---------- */

@media (max-width: 1000px) {
  .ma-stats {
    gap: 16px;
  }

  
}

@media (max-height: 760px) {
  .ma-jeu {
    margin-top: 8px;
    gap: 8px;
  }

  

  
}

@media (max-width: 760px) {
  .ma-jeu {
    padding: 0;
  }

  

  

  .ma-stats {
    order: 3;
    flex-basis: 100%;
    justify-content: space-between;
    gap: 10px;
  }

  

  .ma-progres {
    min-width: 0;
  }

  

  .ma-niveau {
    padding: 0 10px;
  }

  .ma-btn {
    padding: 0 13px;
  }

  /* Le bouton lien suffit : le numéro libère la ligne du titre */
  .ma-grille-num {
    display: none;
  }

  .ma-canvas {
    border-radius: 12px;
  }

  .ma-v-stats {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  #ma-nouvelle span {
    display: none;
  }
}
