/* ===== SportHéros — style enfant, responsive ===== */
:root {
  --bg: #f3f7ff;
  --card: #ffffff;
  --ink: #2d3142;
  --muted: #7b8194;
  --primary: #58cc02;
  --primary-dark: #46a302;
  --accent: #1cb0f6;
  --gold: #ffc800;
  --danger: #ff4b4b;
  --radius: 20px;
  --shadow: 0 4px 14px rgba(45, 49, 66, .08);
  font-size: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  padding-bottom: 90px;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: .92rem; }
.error { color: var(--danger); font-weight: 700; margin-top: 8px; }

/* ---- Topbar ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(135deg, #58cc02, #2fb1f0);
  color: #fff;
  box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: 900px; margin: 0 auto;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
}
.logo { font-weight: 900; font-size: 1.25rem; letter-spacing: .5px; }
.top-stats { display: flex; gap: 8px; }
.stat-chip {
  background: rgba(255,255,255,.22);
  border-radius: 999px; padding: 5px 12px;
  font-size: .9rem; white-space: nowrap;
}

/* ---- Layout ---- */
main { max-width: 900px; margin: 0 auto; padding: 16px; }
.tab { display: none; animation: pop .25s ease; }
.tab.active { display: block; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card h2 { margin-bottom: 8px; font-size: 1.3rem; }
.card h3 { margin-bottom: 8px; font-size: 1.1rem; }

/* ---- Hero ---- */
.hero-card { display: flex; gap: 16px; align-items: center; }
.mascot {
  font-size: 3.5rem; background: #fff7d6;
  border-radius: 50%; width: 84px; height: 84px;
  display: flex; align-items: center; justify-content: center;
  animation: bounce 3s infinite;
}
@keyframes bounce { 0%,100% { transform: translateY(0);} 50% { transform: translateY(-6px);} }
.hero-right { flex: 1; }
.hero-right h1 { font-size: 1.35rem; margin-bottom: 2px; }
.cycle-info { color: var(--muted); font-size: .9rem; margin-bottom: 10px; }

/* ---- XP bar ---- */
.level-block { margin-top: 4px; }
.level-line { display: flex; justify-content: space-between; margin-bottom: 4px; font-size: .95rem; }
.level-name { font-weight: 800; color: var(--primary-dark); }
.level-xp { color: var(--muted); font-size: .85rem; }
.xp-bar {
  height: 16px; background: #e5e9f2; border-radius: 999px; overflow: hidden;
}
.xp-bar.small { height: 10px; }
.xp-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--gold), #ffde59);
  border-radius: 999px;
  transition: width .6s cubic-bezier(.22,1,.36,1);
}
.xp-fill.league-fill { background: linear-gradient(90deg, var(--accent), #6fd6ff); }

/* ---- Exercices ---- */
.exercise-list { list-style: none; }
.exercise-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; margin: 8px 0;
  background: #f6f9ff; border-radius: 14px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: .18s;
  user-select: none;
}
.exercise-list li:hover { border-color: #d6e4ff; }
.exercise-list li.done {
  background: #e9f9df; border-color: var(--primary);
  opacity: .85;
}
.exercise-list li.done .ex-name { text-decoration: line-through; }
.ex-emoji { font-size: 1.7rem; }
.ex-body { flex: 1; }
.ex-name { font-weight: 800; }
.ex-reps { color: var(--muted); font-size: .88rem; }
.ex-check {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid #cfd8ea; display: flex; align-items: center; justify-content: center;
  font-weight: 900; color: #fff; flex-shrink: 0;
}
li.done .ex-check { background: var(--primary); border-color: var(--primary); }
.ex-xp { font-size: .8rem; font-weight: 800; color: var(--gold); white-space: nowrap; }

.workout-done { text-align: center; padding: 12px; }
.big-emoji { font-size: 3rem; }

/* ---- Semaine ---- */
.week-strip { display: flex; gap: 6px; margin: 10px 0; }
.day-dot {
  flex: 1; text-align: center; padding: 8px 2px;
  border-radius: 12px; background: #eef2fa; font-size: .8rem;
}
.day-dot.today { outline: 3px solid var(--accent); }
.day-dot.active { background: #e9f9df; }
.day-dot .d-emoji { font-size: 1.1rem; display: block; }

/* ---- Progression ---- */
.progress-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 10px; margin: 12px 0 18px;
}
.pstat { text-align: center; background: #f6f9ff; border-radius: 14px; padding: 12px 4px; }
.pstat-num { font-size: 1.5rem; font-weight: 900; color: var(--primary-dark); }
.pstat-label { font-size: .8rem; color: var(--muted); }

.chart { display: flex; align-items: flex-end; gap: 8px; height: 140px; padding-top: 10px; }
.chart .bar {
  flex: 1; background: linear-gradient(180deg, #6fd6ff, var(--accent));
  border-radius: 8px 8px 4px 4px; min-height: 4px; position: relative;
}
.chart .bar span {
  position: absolute; bottom: -20px; left: 0; right: 0;
  text-align: center; font-size: .7rem; color: var(--muted);
}
.chart .bar b {
  position: absolute; top: -18px; left: 0; right: 0;
  text-align: center; font-size: .7rem; color: var(--ink);
}
.chart { margin-bottom: 24px; }

.rewards-list, .history-list { list-style: none; }
.rewards-list li, .history-list li {
  padding: 10px 12px; margin: 6px 0; background: #f6f9ff; border-radius: 12px;
  display: flex; gap: 10px; align-items: center; font-size: .95rem;
}

/* ---- Ligue ---- */
.league-ladder { display: flex; flex-direction: column-reverse; gap: 4px; margin: 12px 0; }
.league-step {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 12px; border-radius: 12px; background: #f2f5fb;
  font-size: .92rem; color: var(--muted);
}
.league-step.current {
  background: linear-gradient(90deg, #fff3c4, #ffe89e);
  color: var(--ink); font-weight: 800;
  outline: 2px solid var(--gold);
}
.league-week { margin-top: 14px; }
.league-week p { margin-bottom: 6px; }
.league-rules { margin-top: 12px; font-size: .88rem; color: var(--muted); }
.league-rules p { margin: 4px 0; }

.league-banner {
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
  font-weight: 800; text-align: center; box-shadow: var(--shadow);
  background: #fff;
}
.league-banner.up { background: linear-gradient(135deg, #d3f7b8, #aef1ff); }
.league-banner.stay { background: #fff7d6; }
.league-banner.down { background: #ffe3e3; }

/* ---- Jalons ---- */
.milestone-list, .parent-milestone-list { list-style: none; }
.milestone-list li {
  display: flex; gap: 12px; align-items: center;
  padding: 14px; margin: 8px 0; border-radius: 14px; background: #f6f9ff;
}
.milestone-list li.achieved { background: #e9f9df; }
.ms-emoji { font-size: 1.8rem; }
.ms-body { flex: 1; }
.ms-name { font-weight: 800; }
.ms-reward { font-size: .85rem; color: var(--muted); }
.ms-xp {
  font-weight: 900; color: var(--gold); white-space: nowrap; font-size: .9rem;
  text-align: right;
}
.ms-badge { font-size: 1.4rem; }

.parent-milestone-list li {
  padding: 12px; margin: 8px 0; border-radius: 14px; background: #f6f9ff;
}
.parent-milestone-list .pm-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.parent-milestone-list .pm-name { font-weight: 800; }
.parent-milestone-list input[type="text"] { margin-top: 8px; }
.pm-validate { margin-top: 8px; display: flex; align-items: center; gap: 8px; font-size: .92rem; }
.pm-validate input { width: 20px; height: 20px; accent-color: var(--primary); }
.pm-done { color: var(--primary-dark); font-weight: 800; font-size: .88rem; }

/* ---- Formulaires / boutons ---- */
label { display: block; margin: 10px 0; font-weight: 700; font-size: .95rem; }
input[type="text"], input[type="number"], input[type="password"] {
  width: 100%; padding: 12px; margin-top: 4px;
  border: 2px solid #dde4f0; border-radius: 12px;
  font-size: 1rem; font-family: inherit;
  background: #fff;
}
input:focus { outline: none; border-color: var(--accent); }

.btn {
  display: inline-block; border: none; cursor: pointer;
  background: #e8edf7; color: var(--ink);
  font-weight: 800; font-family: inherit; font-size: 1rem;
  padding: 12px 20px; border-radius: 14px; margin-top: 10px;
  transition: .15s;
}
.btn:hover { filter: brightness(.96); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--primary); color: #fff; box-shadow: 0 3px 0 var(--primary-dark); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.small { padding: 8px 14px; font-size: .85rem; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---- Écrans de connexion / chargement ---- */
.login-screen {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #e8f5ff, #f3fff0);
  padding: 20px;
}
.login-card { max-width: 380px; width: 100%; text-align: center; }
.login-card h1 { font-size: 1.8rem; margin-bottom: 4px; }
.login-emoji { font-size: 3.5rem; margin-bottom: 8px; animation: bounce 3s infinite; }
.login-card input { text-align: center; font-size: 1.15rem; margin-top: 16px; }
.login-card .btn { width: 100%; }

.lock-card { max-width: 420px; margin: 40px auto; text-align: center; }
.lock-card input { text-align: center; font-size: 1.4rem; letter-spacing: .4em; margin-top: 12px; }

/* ---- Illustrations d'exercices ---- */
.ex-svg { width: 100%; height: auto; display: block; }
.ex-svg .membre, .ex-svg .accessoire, .ex-svg .sol, .ex-svg .tete { fill: none; }
.ex-svg .membre {
  stroke: var(--ink); stroke-width: 4.5;
  stroke-linecap: round; stroke-linejoin: round;
}
.ex-svg .tete { stroke: var(--ink); stroke-width: 4.5; fill: #fff; }
.ex-svg .accessoire {
  stroke: #9aa3b8; stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round;
}
.ex-svg .sol { stroke: #d6dced; stroke-width: 2.5; }
.ex-svg .depart { opacity: .3; }
.ex-svg .arrivee .membre, .ex-svg .arrivee .tete { stroke: var(--primary-dark); }
.ex-svg .fleche { fill: #b6bdcd; font-size: 34px; font-weight: 700; }

.ex-info {
  border: none; background: #e8edf7; color: var(--muted);
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  cursor: pointer; font-size: 1rem; line-height: 1;
}
.ex-info:hover { background: #d6e4ff; }

.illu-pop {
  position: absolute; z-index: 60;
  background: #fff; border-radius: 16px; box-shadow: 0 6px 24px rgba(45,49,66,.18);
  padding: 12px; width: 250px; pointer-events: none;
  border: 2px solid #e8edf7;
}
.illu-pop .illu-name {
  font-size: .85rem; font-weight: 800; text-align: center;
  margin-top: 6px; color: var(--ink);
}
.illu-pop .illu-legend { font-size: .72rem; color: var(--muted); text-align: center; }

/* ---- Entraînement au club ---- */
.entr-card { padding: 14px 20px; }
.entr-row {
  display: flex; align-items: center; gap: 12px; cursor: pointer; user-select: none;
}
.entr-emoji { font-size: 1.8rem; }
.entr-body { flex: 1; }
.entr-title { font-weight: 800; display: block; }
.entr-sub { font-size: .82rem; color: var(--muted); }
.entr-xp { font-size: .82rem; font-weight: 800; color: var(--gold); white-space: nowrap; }
.entr-card.actif { background: #e9f9df; }
.entr-card.actif .ex-check { background: var(--primary); border-color: var(--primary); }

.hint { margin-top: 10px; font-size: .82rem; }

/* ---- Test de départ ---- */
.test-progress {
  font-weight: 800; color: var(--primary-dark); margin: 10px 0 4px; font-size: .9rem;
}
.test-cat { margin-top: 14px; }
.test-cat h4 { font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.test-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin: 6px 0; background: #f6f9ff; border-radius: 12px;
}
.test-row.rempli { background: #e9f9df; }
.test-name { flex: 1; font-size: .92rem; font-weight: 700; }
.test-row input[type="number"] {
  width: 78px; margin: 0; padding: 8px; text-align: center;
}
.test-unit { font-size: .8rem; color: var(--muted); width: 40px; }
.test-base { font-size: .78rem; color: var(--primary-dark); font-weight: 800; width: 82px; text-align: right; }

/* ---- Défis : édition ---- */
.pm-fields { display: grid; grid-template-columns: 60px 1fr 90px; gap: 8px; margin-top: 8px; }
.pm-fields input { margin-top: 0; }
.pm-fields .pm-full { grid-column: 1 / -1; }
.pm-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.pm-badge-perso {
  font-size: .7rem; background: #e8edf7; color: var(--muted);
  padding: 2px 8px; border-radius: 999px; font-weight: 800;
}
.new-challenge { margin-top: 14px; }
.new-challenge summary {
  cursor: pointer; font-weight: 800; color: var(--primary-dark);
  padding: 10px; background: #f0f7ea; border-radius: 12px;
}
.new-challenge-form { padding: 10px 4px; }

.league-manual {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; margin-bottom: 4px;
}
.sep { border: none; border-top: 2px solid #eef2fa; margin: 16px 0; }

/* ---- Nav basse ---- */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  background: #fff; box-shadow: 0 -4px 14px rgba(45,49,66,.1);
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.navbtn {
  border: none; background: none; cursor: pointer;
  font-family: inherit; font-size: .72rem; font-weight: 800;
  color: var(--muted); display: flex; flex-direction: column; align-items: center;
  gap: 2px; padding: 6px 10px; border-radius: 12px;
}
.navbtn span { font-size: 1.45rem; }
.navbtn.active { color: var(--primary-dark); background: #e9f9df; }

/* ---- Toast & confetti ---- */
.toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 20px;
  border-radius: 999px; font-weight: 800; z-index: 50;
  box-shadow: var(--shadow); max-width: 90vw; text-align: center;
  animation: pop .25s ease;
}
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.confetto {
  position: absolute; top: -20px; font-size: 1.4rem;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); opacity: .6; }
}

/* ---- Desktop ---- */
@media (min-width: 720px) {
  :root { font-size: 17px; }
  .bottomnav {
    position: sticky; top: 0; bottom: auto; max-width: 900px; margin: 0 auto;
    border-radius: 0 0 var(--radius) var(--radius);
    justify-content: center; gap: 24px;
  }
  body { padding-bottom: 20px; }
  .navbtn { flex-direction: row; font-size: .95rem; }
  .navbtn span { font-size: 1.2rem; }
  .progress-grid { grid-template-columns: repeat(4, 1fr); }
}
