/* =========================================================
   Fiches Famille : style ludique (couleurs vives, formes rondes,
   boutons en relief, petites animations). Sans dépendance.
   ========================================================= */
[hidden] { display: none !important; }

:root {
  --bg: #fff7ec;
  --card: #ffffff;
  --ink: #2b2346;
  --muted: #7a7191;
  --line: #eee4f7;
  --primary: #7c5cff;      /* violet */
  --primary-dark: #5a3fd6;
  --ok: #22c55e;
  --ok-dark: #16a34a;
  --ko: #ff5d73;
  --ko-dark: #e23d55;
  --sun: #ffc93c;
  --sky: #38bdf8;
  --radius: 22px;
  --shadow: 0 6px 0 rgba(43, 35, 70, .08), 0 14px 30px rgba(43, 35, 70, .08);
  /* Boîtes de Leitner : de « à apprendre » (rouge) à « maîtrisé » (vert) */
  --b0: #c7c2d6; --b1: #ff5d73; --b2: #ff9f43; --b3: #ffc93c; --b4: #8bd450; --b5: #22c55e;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 12%, #ffe1f0 0 120px, transparent 121px),
    radial-gradient(circle at 92% 30%, #dff3ff 0 160px, transparent 161px),
    radial-gradient(circle at 15% 85%, #e5ffe0 0 140px, transparent 141px),
    radial-gradient(circle at 85% 90%, #fff0c2 0 120px, transparent 121px),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
}
a { color: var(--primary-dark); font-weight: 700; }
h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); margin: 0 0 16px; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; margin: 30px 0 12px; display: flex; align-items: center; gap: 8px; }
h3 { margin: 16px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.narrow { max-width: 480px; }

/* ---------- Barre du haut ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px; position: sticky; top: 0; z-index: 5;
  background: linear-gradient(90deg, #7c5cff, #b45cff 45%, #ff6fb1);
  box-shadow: 0 4px 0 rgba(90, 63, 214, .35);
}
.brand { color: #fff; text-decoration: none; font-weight: 900; font-size: 1.25rem; letter-spacing: .01em; text-shadow: 0 2px 0 rgba(0,0,0,.15); }
.who {
  border: none; background: rgba(255,255,255,.95); color: var(--ink); border-radius: 999px;
  padding: 8px 16px; cursor: pointer; font: inherit; font-weight: 800; box-shadow: 0 3px 0 rgba(0,0,0,.15);
}
.menuwrap { position: relative; }
.menu {
  position: absolute; right: 0; top: 50px; background: var(--card); border-radius: 18px;
  box-shadow: var(--shadow); min-width: 210px; overflow: hidden; padding: 6px; animation: pop .15s ease-out;
}
.menu a, .menu button {
  display: block; width: 100%; text-align: left; padding: 11px 14px; background: none; color: var(--ink);
  border-radius: 12px; text-decoration: none; font: inherit; font-weight: 700; border: none; box-shadow: none; cursor: pointer;
}
.menu a:hover, .menu button:hover { background: #f4efff; transform: none; }
.menu a[hidden] { display: none; }

main { max-width: 900px; margin: 0 auto; padding: 26px 16px 70px; }

/* ---------- Panneaux ---------- */
.panel {
  background: var(--card); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); border: 2px solid #fff;
}
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.empty { text-align: center; padding: 30px; color: var(--muted); }

/* ---------- Boutons en relief ---------- */
button, .btn {
  font: inherit; font-weight: 800; border: none; border-radius: 16px; padding: 11px 18px; cursor: pointer;
  background: var(--primary); color: #fff; text-decoration: none; display: inline-block;
  box-shadow: 0 5px 0 var(--primary-dark); transition: transform .08s, box-shadow .08s, filter .15s;
  position: relative; top: 0;
}
button:hover:not(:disabled), .btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
button:active:not(:disabled), .btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--primary-dark); }
button.secondary, .btn.secondary { background: #fff; color: var(--ink); box-shadow: 0 5px 0 #ddd3ee; border: 2px solid #eee6fa; }
button.danger { background: #fff; color: var(--ko-dark); box-shadow: 0 4px 0 #ffd0d7; border: 2px solid #ffe1e6; }
button.small, .btn.small { padding: 7px 12px; font-size: .85rem; border-radius: 12px; }
button:disabled { opacity: .45; cursor: default; }
.ok { background: var(--ok) !important; box-shadow: 0 5px 0 var(--ok-dark) !important; }
.ko { background: var(--ko) !important; box-shadow: 0 5px 0 var(--ko-dark) !important; }

/* ---------- Formulaires ---------- */
input, textarea, select {
  font: inherit; width: 100%; padding: 12px 14px; border: 2px solid #ece3fb; border-radius: 14px;
  background: #fcfaff; color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(124, 92, 255, .18); background: #fff; }
select { width: auto; max-width: 100%; min-width: 0; text-overflow: ellipsis; cursor: pointer; }
textarea { min-height: 76px; resize: vertical; }
label { display: block; font-size: .85rem; font-weight: 800; color: var(--muted); margin: 12px 0 5px; }
form .row > div, form .row > input { flex: 1; min-width: 180px; }

/* ---------- Profils ---------- */
.profiles { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); margin-top: 20px; }
.profile {
  background: var(--card); border-radius: 26px; padding: 22px 10px; text-align: center; cursor: pointer;
  box-shadow: var(--shadow); border: 3px solid transparent; transition: transform .15s, border-color .15s;
}
.profile:nth-child(4n+1) { background: #fff0f6; }
.profile:nth-child(4n+2) { background: #eef8ff; }
.profile:nth-child(4n+3) { background: #f0fff0; }
.profile:nth-child(4n+4) { background: #fff8e1; }
.profile:hover { transform: translateY(-4px) rotate(-1.5deg); }
.profile.on { border-color: var(--primary); transform: scale(1.03); }
.profile .avatar { font-size: 3.4rem; line-height: 1.1; }
.profile .name { margin-top: 8px; font-weight: 900; font-size: 1.1rem; }
.avatars { display: flex; flex-wrap: wrap; gap: 6px; }
.avatars button {
  background: #f6f2ff; border: 3px solid transparent; font-size: 1.6rem; padding: 4px 8px;
  box-shadow: none; border-radius: 14px;
}
.avatars button.on { border-color: var(--primary); background: #fff; transform: scale(1.12); }
.code-input { font-size: 1.6rem; letter-spacing: .45em; text-align: center; font-weight: 900; }
#pinForm { margin: 22px auto 0; }

/* ---------- Thèmes ---------- */
.theme {
  text-decoration: none; color: var(--ink); display: block; position: relative; overflow: hidden;
  border: none; border-top: 8px solid var(--c, var(--primary)); transition: transform .15s;
}
a.theme:hover { transform: translateY(-4px) rotate(-.6deg); }
.theme::after {
  content: ""; position: absolute; right: -30px; bottom: -30px; width: 110px; height: 110px; border-radius: 50%;
  background: var(--c, var(--primary)); opacity: .1;
}
.theme .title { font-weight: 900; font-size: 1.12rem; display: flex; align-items: center; gap: 8px; }
.theme .ico { font-size: 1.5rem; }
.badge {
  display: inline-block; border-radius: 999px; padding: 3px 11px; font-size: .78rem; font-weight: 800;
  background: #f4efff; color: #5a3fd6; margin: 2px 2px 2px 0;
}
.badge.due { background: #fff1d6; color: #b45309; }
.badge.lvl { background: #e0f2fe; color: #0369a1; }
.colors { display: flex; gap: 6px; flex-wrap: wrap; }
.colors button { width: 30px; height: 30px; padding: 0; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 2px 0 rgba(0,0,0,.15); }
.colors button.on { outline: 3px solid var(--ink); }

/* ---------- Boîtes de Leitner ---------- */
.boxes { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.box {
  text-align: center; padding: 12px 4px 10px; border-radius: 18px; background: var(--card);
  box-shadow: 0 5px 0 var(--bc), 0 10px 20px rgba(43,35,70,.06); border: 2px solid var(--bc);
}
.box .n { font-size: 1.6rem; font-weight: 900; color: var(--ink); }
.box .l { font-size: .72rem; color: var(--muted); font-weight: 700; }
.pill { display: inline-block; min-width: 26px; text-align: center; border-radius: 999px; padding: 2px 8px; font-size: .78rem; font-weight: 900; color: #fff; background: var(--bc); }
@media (max-width: 640px) { .boxes { grid-template-columns: repeat(3, 1fr); } }

/* ---------- Liste des fiches ---------- */
.cardrow { display: grid; grid-template-columns: auto 1fr 1fr auto; gap: 12px; align-items: start; padding: 14px 0; border-bottom: 2px dashed var(--line); }
.cardrow:last-child { border-bottom: none; }
.cardrow .q { font-weight: 800; white-space: pre-wrap; }
.cardrow .a { color: var(--muted); white-space: pre-wrap; }
.cardrow label { margin-top: 6px; }
@media (max-width: 640px) {
  .cardrow { grid-template-columns: auto 1fr; }
  .cardrow .a, .cardrow > .row { grid-column: 2; }
  .cardrow.editing { grid-template-columns: 1fr; }
  .cardrow.editing > * { grid-column: 1; }
  .cardrow.editing > span:first-child { display: none; }
}

/* ---------- Révision (carte retournée) ---------- */
.flash {
  min-height: 260px; display: flex; flex-direction: column; justify-content: center; align-items: center;
  text-align: center; padding: 34px 22px; font-size: clamp(1.2rem, 3.6vw, 1.55rem); font-weight: 800; white-space: pre-wrap;
  background: linear-gradient(160deg, #ffffff, #f7f2ff); border: 3px solid #efe7ff; animation: flip .35s ease-out;
}
.flash .answer {
  margin-top: 22px; padding-top: 22px; border-top: 3px dashed #e5dbff; width: 100%; color: var(--primary-dark);
  animation: pop .25s ease-out;
}
.hidden-answer { color: #e3dafa !important; letter-spacing: .4em; animation: none !important; }
.progressbar { height: 14px; background: #fff; border-radius: 99px; overflow: hidden; margin: 12px 0 18px; box-shadow: inset 0 2px 4px rgba(0,0,0,.08); }
.progressbar > div {
  height: 100%; border-radius: 99px; transition: width .3s;
  background: repeating-linear-gradient(45deg, #7c5cff 0 14px, #9b7bff 14px 28px);
}
.actions { display: flex; gap: 14px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.actions button { min-width: 170px; padding: 15px 20px; font-size: 1.08rem; }
.kbd { font-size: .72rem; opacity: .75; font-weight: 700; }
@media (max-width: 640px) { .actions button { flex: 1; min-width: 0; } }

/* ---------- Quiz ---------- */
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
@media (max-width: 640px) { .choices { grid-template-columns: 1fr; } }
.choice {
  color: var(--ink); text-align: left; padding: 18px; font-size: 1.08rem; border-radius: 18px;
  background: #fff; border: 3px solid #eee6fa; box-shadow: 0 5px 0 #ddd3ee; animation: pop .25s ease-out both;
}
.choice:nth-child(1) { --tint: #ff5d73; } .choice:nth-child(2) { --tint: #38bdf8; }
.choice:nth-child(3) { --tint: #ffc93c; } .choice:nth-child(4) { --tint: #22c55e; }
.choice:nth-child(2) { animation-delay: .04s; } .choice:nth-child(3) { animation-delay: .08s; } .choice:nth-child(4) { animation-delay: .12s; }
.choice:hover:not(:disabled) { border-color: var(--tint); }
.choice .kbd {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; margin-right: 8px;
  background: var(--tint); color: #fff; opacity: 1; font-size: .85rem;
}
.choice.good { border-color: var(--ok); background: #dcfce7; box-shadow: 0 5px 0 var(--ok-dark); opacity: 1; animation: bounce .45s; }
.choice.bad { border-color: var(--ko); background: #ffe4e8; box-shadow: 0 5px 0 var(--ko-dark); opacity: 1; animation: shake .4s; }
.choice.dim { opacity: .4; }
.players { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: flex; align-items: center; gap: 6px; margin: 0; padding: 8px 14px; border-radius: 999px; cursor: pointer;
  background: #f6f2ff; color: var(--ink); font-size: 1rem; font-weight: 800; border: 2px solid transparent;
}
.chip:has(input:checked) { background: #fff; border-color: var(--primary); }
.chip input { width: auto; accent-color: var(--primary); }
.ranking { padding-left: 0; margin: 10px 0; text-align: left; list-style: none; counter-reset: rk; }
.ranking li { counter-increment: rk; padding: 8px 10px; border-radius: 12px; display: flex; justify-content: space-between; gap: 10px; }
.ranking li::before { content: counter(rk); font-weight: 900; color: var(--muted); margin-right: 6px; }
.ranking li:first-child { background: #fff6d6; }
.ranking li:first-child::before { content: "🥇"; }
.ranking li:nth-child(2)::before { content: "🥈"; }
.ranking li:nth-child(3)::before { content: "🥉"; }
.ranking li span:first-child { flex: 1; }
.board { width: 100%; border-collapse: separate; border-spacing: 0 6px; }
.board th { text-align: left; font-size: .75rem; color: var(--muted); font-weight: 800; padding: 0 8px; text-transform: uppercase; letter-spacing: .04em; }
.board td { padding: 10px 8px; background: #faf7ff; font-weight: 700; }
.board td:first-child { border-radius: 12px 0 0 12px; font-size: 1.2rem; }
.board td:last-child { border-radius: 0 12px 12px 0; }
.board tr:first-child td { background: #fff6d6; }
@media (max-width: 640px) {
  .board th:nth-child(5), .board td:nth-child(5) { display: none; }
  .board th { font-size: .62rem; letter-spacing: 0; padding: 0 4px; }
  .board td { padding: 8px 4px; font-size: .9rem; }
  .board td:nth-child(2) { word-break: break-word; }
}

/* ---------- Famille, comptes ---------- */
.invite, .member { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 0; border-bottom: 2px dashed var(--line); }
.invite:last-child, .member:last-child { border-bottom: none; }
.invite .code {
  font-family: ui-monospace, monospace; font-size: 1.8rem; font-weight: 900; letter-spacing: .25em;
  color: #fff; background: linear-gradient(90deg, #7c5cff, #ff6fb1); padding: 4px 14px; border-radius: 14px;
}
#invites { margin-top: 10px; }
.once { margin: 12px 0; padding: 14px; background: #fff6d6; border: 2px dashed #ffc93c; border-radius: 16px; }
.once code { display: block; margin: 8px 0; word-break: break-all; font-size: .9rem; user-select: all; }
.member select, #themeLevel select { padding: 6px 10px; font-size: .85rem; border-radius: 12px; }
.switch { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--ink); font-size: .9rem; cursor: pointer; }
.switch input { width: auto; accent-color: var(--primary); }

/* ---------- Message éphémère ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 20;
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 16px; font-weight: 800;
  box-shadow: 0 6px 0 rgba(0,0,0,.2); animation: pop .2s ease-out;
}

/* ---------- Écrans de fin ---------- */
.celebrate { font-size: 3.5rem; animation: bounce .8s ease-in-out infinite alternate; display: inline-block; }
.score-big { font-size: 2.4rem; font-weight: 900; color: var(--primary-dark); }

/* Confettis */
.confetti { position: fixed; top: -12px; width: 10px; height: 14px; border-radius: 3px; z-index: 30; pointer-events: none; animation: fall linear forwards; }

/* ---------- Animations ---------- */
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes flip { from { transform: perspective(800px) rotateX(-12deg); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes bounce { 0% { transform: scale(1); } 40% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-7px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  main { padding: 18px 12px 60px; }
  .panel { padding: 15px; border-radius: 18px; }
  .brand { font-size: 1.05rem; }
  .who { padding: 7px 12px; font-size: .9rem; }
  h2 { font-size: 1.08rem; }
  .grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .theme .title { font-size: 1rem; }
}
@media (max-width: 400px) { .grid { grid-template-columns: 1fr; } }

/* Écrans tactiles : pas de raccourcis clavier affichés (sauf les numéros des réponses) */
@media (hover: none) {
  button .kbd { display: none; }
  .choice .kbd { display: inline-grid; }
}
.empty h2, .empty .ranking { color: var(--ink); }
