/* Cagnottes Séminaire — direction artistique (cahier des charges v0.5, section 7)
   Un jeu pour adultes avec les souvenirs visuels de l'enfance : cour de récré,
   cahiers, autocollants, cartes à collectionner, billes, badges, tampons, trophées.
   Surtout pas une esthétique d'app bancaire / outil de gestion. */

@import url("https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;700;800&family=Nunito:wght@400;600;700;800&display=swap");

:root {
  --yellow: #ffd166;
  --coral: #ff6b6b;
  --sky: #4ecdc4;
  --sky-deep: #3aa9c9;
  --mint: #6bcB77;
  --orange: #ff9f45;
  --violet: #a78bfa;
  --pink: #ff8fab;
  --cream: #fff8ec;
  --paper: #fffdf7;
  --ink: #3a2e2e;
  --ink-soft: #6b5b5b;
  --line: #f0e0c0;

  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
  --shadow-pop: 0 6px 0 rgba(58, 46, 46, 0.18);
  --shadow-card: 0 10px 24px rgba(58, 46, 46, 0.1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--cream);
  background-image:
    radial-gradient(circle at 8% 12%, rgba(255, 209, 102, 0.35) 0, transparent 40%),
    radial-gradient(circle at 92% 85%, rgba(78, 205, 196, 0.28) 0, transparent 42%);
  color: var(--ink);
  font-family: "Nunito", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .title-font {
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-weight: 800;
  margin: 0 0 0.4em;
  letter-spacing: 0.2px;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 16px 16px 96px;
  position: relative;
}

p { line-height: 1.45; }

/* Contenu toujours visible même si l'animation est throttlée (onglet en
   arrière-plan, mode économie d'énergie) : seul le transform est animé. */
.screen { opacity: 1; animation: rise 0.25s ease; }
@keyframes rise { from { transform: translateY(10px); } to { transform: translateY(0); } }

/* ---------- Boutons "gonflés" ---------- */
.btn {
  font-family: "Baloo 2", sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 22px;
  cursor: pointer;
  color: white;
  background: var(--sky-deep);
  box-shadow: var(--shadow-pop);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(58, 46, 46, 0.18); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: var(--shadow-pop); }

.btn-yes, .btn-accept { background: #4caf6a; }
.btn-no, .btn-refuse, .btn-danger { background: var(--coral); }
.btn-caid { background: var(--orange); }
.btn-admin { background: var(--violet); }
.btn-ghost {
  background: transparent;
  color: var(--ink);
  box-shadow: none;
  border: 2px dashed var(--line);
}
.btn-ghost:active { transform: none; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { width: auto; flex: 1; }

/* ---------- Cartes façon jeu ---------- */
.card {
  background: var(--paper);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
  border: 3px solid white;
  outline: 2px solid var(--line);
  outline-offset: -6px;
  margin-bottom: 16px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: "Baloo 2", sans-serif;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--yellow);
  color: #6b4b00;
  box-shadow: 0 2px 0 rgba(0,0,0,0.08);
}
.badge-caid { background: var(--orange); color: #5a2a00; }
.badge-organizer { background: var(--violet); color: #2f1b5c; }

/* ---------- Carnet d'élève (ex "carte de joueur") ---------- */
.player-card {
  background: linear-gradient(160deg, #fff, #fff6df);
  border-radius: var(--radius-lg);
  padding: 22px;
  text-align: center;
  box-shadow: var(--shadow-card);
  border: 3px solid white;
  outline: 3px dashed var(--yellow);
  outline-offset: -10px;
  position: relative;
}
.player-avatar {
  font-size: 3.6rem;
  width: 96px;
  height: 96px;
  line-height: 96px;
  border-radius: 50%;
  background: white;
  box-shadow: var(--shadow-pop);
  margin: 0 auto 10px;
}
.player-name { font-size: 1.4rem; }
.token-counter {
  font-family: "Baloo 2", sans-serif;
  font-weight: 800;
  font-size: 2.6rem;
  color: var(--sky-deep);
  margin: 6px 0;
}
.token-counter.bump { animation: bump 0.4s ease; }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }
.token-counter.drop { animation: drop 0.4s ease; color: var(--coral); }
@keyframes drop { 0% { transform: translateX(0); } 30% { transform: translateX(-6px); } 60% { transform: translateX(6px); } 100% { transform: translateX(0); } }

.specialty-tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 10px; }
.specialty-tag {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink);
  background: white;
  border: 2px solid var(--sky);
  border-radius: 999px;
  padding: 3px 10px;
}

.qr-wrap {
  background: white;
  border-radius: var(--radius-md);
  padding: 14px;
  display: inline-block;
  box-shadow: var(--shadow-pop);
  margin-top: 10px;
}

/* ---------- Classement / podium ---------- */
.podium { display: flex; align-items: flex-end; gap: 8px; margin: 18px 0; }
.podium-spot { flex: 1; text-align: center; }
.podium-step {
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  padding: 10px 6px;
  color: white;
  font-family: "Baloo 2", sans-serif;
  font-weight: 800;
  box-shadow: var(--shadow-pop);
}
.podium-spot.gold .podium-step { background: var(--yellow); color: #6b4b00; height: 128px; }
.podium-spot.silver .podium-step { background: #cfd8e3; color: #3a4351; height: 100px; }
.podium-spot.bronze .podium-step { background: #e3ab74; color: #5a3410; height: 82px; }
.podium-avatar { font-size: 2.2rem; margin-bottom: 4px; }

.rank-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--paper);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 8px;
  box-shadow: 0 3px 0 rgba(58,46,46,0.08);
}
.rank-row.me { outline: 3px solid var(--sky); outline-offset: -3px; }
.rank-num { font-family: "Baloo 2", sans-serif; font-weight: 800; width: 28px; color: var(--ink-soft); }
.rank-avatar { font-size: 1.6rem; }
.rank-name { flex: 1; font-weight: 700; }
.rank-tokens { font-family: "Baloo 2", sans-serif; font-weight: 800; color: var(--sky-deep); }

/* ---------- Navigation ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.topbar .brand { font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 1.2rem; }
.icon-btn {
  background: white;
  border: none;
  border-radius: 50%;
  width: 40px; height: 40px;
  box-shadow: var(--shadow-pop);
  cursor: pointer;
  font-size: 1.1rem;
}
.icon-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(58,46,46,0.18); }

.bottom-nav {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 448px;
  background: var(--paper);
  border-radius: 999px;
  box-shadow: var(--shadow-card);
  display: flex;
  padding: 6px;
  gap: 4px;
  z-index: 20;
}
.bottom-nav button {
  flex: 1;
  border: none;
  background: transparent;
  border-radius: 999px;
  padding: 10px 4px;
  font-family: "Baloo 2", sans-serif;
  font-weight: 700;
  font-size: 0.72rem;
  color: var(--ink-soft);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  cursor: pointer;
  position: relative;
}
.bottom-nav button.active { background: var(--yellow); color: #6b4b00; }
.bottom-nav .dot {
  position: absolute; top: 2px; right: 14px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--coral);
}

/* ---------- Formulaires ---------- */
input, select, textarea {
  font-family: "Nunito", sans-serif;
  font-size: 1rem;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--line);
  background: white;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--sky); border-color: var(--sky); }
label { font-weight: 700; font-size: 0.88rem; color: var(--ink-soft); display: block; margin: 10px 0 4px; }

.field { margin-bottom: 6px; }
.error-box {
  background: #fff0ef;
  border: 2px solid var(--coral);
  color: #9a2f2f;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-weight: 700;
  margin: 10px 0;
}
.hint { color: var(--ink-soft); font-size: 0.88rem; }
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.spacer { height: 12px; }

/* ---------- Minuteur ---------- */
.timer-ring-wrap { display: flex; justify-content: center; margin: 16px 0; }
.timer-num { font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 2.4rem; color: var(--coral); }

/* ---------- Avatars sélecteur ---------- */
.avatar-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.avatar-choice {
  font-size: 1.8rem;
  background: white;
  border: 3px solid var(--line);
  border-radius: var(--radius-sm);
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.avatar-choice.selected { border-color: var(--sky); background: #eaffff; }

/* ---------- Scanner QR ---------- */
.scanner-wrap {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  background: black;
  aspect-ratio: 1;
}
.scanner-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner-frame {
  position: absolute; inset: 12%;
  border: 4px solid var(--yellow);
  border-radius: var(--radius-md);
  box-shadow: 0 0 0 999px rgba(0,0,0,0.35);
}

/* ---------- Confettis ---------- */
#confetti-canvas {
  position: fixed; inset: 0; pointer-events: none; z-index: 999;
}

/* ---------- Crown ---------- */
.crown-banner {
  text-align: center;
  padding: 18px;
  background: linear-gradient(160deg, var(--orange), #ffb066);
  color: #5a2a00;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
}
.crown-banner .crown-icon { font-size: 2.4rem; }

.empty-state { text-align: center; padding: 40px 16px; color: var(--ink-soft); }
.empty-state .big { font-size: 2.6rem; margin-bottom: 6px; }

table.history-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.history-table td { padding: 8px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
