/* === Math Runner — page de jeu (solo.php) ===
   HUD + canvas + overlay fin. */

.mr-game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 14px 8px 30px;
  max-width: 540px;
  margin: 0 auto;
}

.mr-mode-titre {
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #a3e635;
  margin: 0;
  text-align: center;
}
.mr-mode-titre .mode-defi {
  color: #fb923c;
}

/* HUD */
.mr-hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 540px;
}
.mr-hud-cell {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(132, 204, 22, 0.18);
  border-radius: 10px;
  padding: 8px 6px;
  text-align: center;
  min-width: 0;
}
.mr-hud-cell .label {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #94a3b8;
  margin-bottom: 3px;
}
.mr-hud-cell .val {
  display: block;
  font-size: 1.3rem;
  font-weight: 800;
  color: #f1f5f9;
}
.mr-hud-cell.hud-troupe .val { color: #a3e635; }
.mr-hud-cell.hud-temps .val { color: #fb923c; }

/* Canvas */
.mr-canvas-wrap {
  position: relative;
  width: 100%;
  max-width: 540px;
  aspect-ratio: 9 / 14;
  border-radius: 14px;
  overflow: hidden;
  background: #0f172a;
  box-shadow: 0 0 28px rgba(132, 204, 22, 0.12), 0 8px 30px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(132, 204, 22, 0.22);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.mr-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Indicateur "appuyez pour bouger" */
.mr-tip {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.55);
  text-align: center;
  margin: 4px 0 0;
}
.mr-tip kbd {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 5px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.16);
  font-family: monospace;
  font-size: 0.78rem;
}

/* Overlay fin de partie */
.mr-overlay-fin {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(15, 23, 42, 0.86);
  border-radius: 14px;
  padding: 24px 20px;
  z-index: 5;
}
.mr-overlay-fin.visible { display: flex; }
.mr-overlay-fin h2 {
  font-size: 1.5rem;
  margin: 0 0 14px;
  color: #f87171;
}
.mr-overlay-fin .stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 360px;
  margin-bottom: 18px;
}
.mr-overlay-fin .stats > div {
  background: rgba(255,255,255,0.06);
  border-radius: 8px;
  padding: 10px 6px;
}
.mr-overlay-fin .stats .label {
  display: block;
  font-size: 0.7rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}
.mr-overlay-fin .stats .val {
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
}
.mr-overlay-fin .stats .val-score { color: #a3e635; }

.mr-overlay-fin .actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.mr-overlay-fin .btn-rejouer,
.mr-overlay-fin .btn-accueil {
  display: inline-block;
  padding: 11px 22px;
  border-radius: 10px;
  font-weight: 700;
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
}
.mr-overlay-fin .btn-rejouer {
  background: linear-gradient(135deg, #a3e635, #84cc16);
  color: #0f172a;
}
.mr-overlay-fin .btn-accueil {
  background: rgba(255,255,255,0.1);
  color: #f1f5f9;
  border: 1px solid rgba(255,255,255,0.2);
}
.mr-overlay-fin .btn-rejouer:hover { transform: scale(1.04); }
.mr-overlay-fin .btn-accueil:hover { background: rgba(255,255,255,0.18); }

/* Message connexion (mode défi) */
.mr-connexion-requise {
  background: rgba(251, 146, 60, 0.1);
  border: 1px solid rgba(251, 146, 60, 0.4);
  color: #fed7aa;
  padding: 14px 16px;
  border-radius: 10px;
  text-align: center;
  margin: 0 auto;
  max-width: 460px;
}
.mr-connexion-requise a {
  color: #fb923c;
  font-weight: 700;
}

/* Boutons mode au-dessus du canvas */
.mr-modes-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.mr-modes-bar a {
  padding: 8px 16px;
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  text-decoration: none;
  color: #cbd5e1;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.18s;
}
.mr-modes-bar a.actif {
  background: linear-gradient(135deg, rgba(132, 204, 22, 0.2), rgba(132, 204, 22, 0.08));
  border-color: rgba(163, 230, 53, 0.55);
  color: #d9f99d;
}
.mr-modes-bar a:hover { background: rgba(255,255,255,0.12); }

@media (max-width: 480px) {
  .mr-canvas-wrap { aspect-ratio: 9 / 15; }
  .mr-hud-cell .val { font-size: 1.1rem; }
  .mr-overlay-fin h2 { font-size: 1.25rem; }
}
