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

    :root {
      --rouge:    #E8263A;
      --jaune:    #FFD02F;
      --bleu:     #1A73E8;
      --vert:     #22C55E;
      --orange:   #FF7A2F;
      --fond:     #FFF8EE;
      --blanc:    #FFFFFF;
      --texte:    #2D1B00;
      --ombre:    rgba(0,0,0,.12);
      --radius:   20px;
    }

    body {
      font-family: 'Nunito', sans-serif;
      background-color: var(--fond);
      color: var(--texte);
      min-height: 100vh;
      overflow-x: hidden;
      background-image:
        radial-gradient(circle at 10% 20%, rgba(255,208,47,.18) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(232,38,58,.12) 0%, transparent 40%);
    }

    /* ===== GUIRLANDE HAUT ===== */
    .guirlande {
      width: 100%;
      height: 28px;
      display: flex;
      align-items: flex-end;
      justify-content: center;
      gap: 0;
      background: transparent;
      position: relative;
      padding-top: 4px;
      overflow: hidden;
    }
    .guirlande::before {
      content: '';
      position: absolute;
      top: 2px; left: -10px; right: -10px;
      height: 3px;
      background: repeating-linear-gradient(90deg,
        var(--rouge) 0px, var(--rouge) 30px,
        var(--jaune) 30px, var(--jaune) 60px,
        var(--bleu) 60px, var(--bleu) 90px,
        var(--vert) 90px, var(--vert) 120px);
      border-radius: 2px;
    }
    .ampoule {
      width: 18px; height: 22px;
      border-radius: 50% 50% 40% 40%;
      margin: 0 16px;
      position: relative;
      top: 0;
      animation: clignoter 3s infinite;
      box-shadow: 0 0 8px 2px currentColor;
    }
    .ampoule:nth-child(1)  { background: var(--rouge);  color: var(--rouge);  animation-delay: 0s; }
    .ampoule:nth-child(2)  { background: var(--jaune);  color: var(--jaune);  animation-delay: .4s; }
    .ampoule:nth-child(3)  { background: var(--bleu);   color: var(--bleu);   animation-delay: .8s; }
    .ampoule:nth-child(4)  { background: var(--vert);   color: var(--vert);   animation-delay: 1.2s; }
    .ampoule:nth-child(5)  { background: var(--orange); color: var(--orange); animation-delay: 1.6s; }
    .ampoule:nth-child(6)  { background: var(--rouge);  color: var(--rouge);  animation-delay: 2.0s; }
    .ampoule:nth-child(7)  { background: var(--jaune);  color: var(--jaune);  animation-delay: 0.2s; }
    .ampoule:nth-child(8)  { background: var(--bleu);   color: var(--bleu);   animation-delay: 0.6s; }
    .ampoule:nth-child(9)  { background: var(--vert);   color: var(--vert);   animation-delay: 1.0s; }
    .ampoule:nth-child(10) { background: var(--orange); color: var(--orange); animation-delay: 1.4s; }
    @keyframes clignoter {
      0%,100%  { opacity: 1; }
      50%      { opacity: .35; }
    }

    /* ===== WRAPPER GLOBAL ===== */
    .wrapper {
      max-width: 600px;
      margin: 0 auto;
      padding: 0 16px 60px;
    }

    /* ===== HEADER ===== */
    header {
      text-align: center;
      padding: 36px 20px 24px;
      animation: fadeDown .7s ease both;
    }
    header h1 {
      font-family: 'Fredoka One', cursive;
      font-size: clamp(2rem, 8vw, 3.2rem);
      color: var(--rouge);
      text-shadow: 3px 3px 0 var(--jaune), 5px 5px 0 rgba(0,0,0,.08);
      letter-spacing: 1px;
      line-height: 1.1;
    }
    header h1 span { color: var(--bleu); }
    @keyframes fadeDown {
      from { opacity: 0; transform: translateY(-24px); }
      to   { opacity: 1; transform: translateY(0); }
    }

    /* ===== SECTIONS ===== */
    .section {
      background: var(--blanc);
      border-radius: var(--radius);
      padding: 32px 28px;
      margin-bottom: 24px;
      box-shadow: 0 4px 24px var(--ombre);
      border: 2px solid transparent;
      animation: fadeUp .6s ease both;
    }
    .section:nth-child(2) { animation-delay: .1s; }
    .section:nth-child(3) { animation-delay: .2s; }
    .section:nth-child(4) { animation-delay: .3s; }
    @keyframes fadeUp {
      from { opacity: 0; transform: translateY(30px); }
      to   { opacity: 1; transform: translateY(0); }
    }

    .section h2 {
      font-family: 'Fredoka One', cursive;
      font-size: 1.5rem;
      margin-bottom: 20px;
      display: flex;
      align-items: center;
      gap: 10px;
    }

    /* ===== SECTION ACCUEIL (#home) ===== */
    #home { border-color: var(--jaune); background: linear-gradient(145deg, #fffdf5, #fff8e1); }
    #home h2 { color: var(--rouge); font-size: 1.8rem; justify-content: center; }

    .accroche {
      text-align: center;
      font-size: 1.1rem;
      font-weight: 700;
      color: #5a3e00;
      margin-bottom: 20px;
    }

    .regles {
      list-style: none;
      display: flex;
      flex-direction: column;
      gap: 10px;
      margin-bottom: 28px;
    }
    .regles li {
      background: var(--fond);
      border-left: 4px solid var(--jaune);
      border-radius: 10px;
      padding: 10px 16px;
      font-size: .98rem;
      font-weight: 600;
    }

    /* ===== BOUTONS ===== */
    .btn {
      display: inline-block;
      font-family: 'Fredoka One', cursive;
      font-size: 1.15rem;
      letter-spacing: .5px;
      padding: 14px 36px;
      border: none;
      border-radius: 50px;
      cursor: pointer;
      transition: transform .15s, box-shadow .15s;
      text-decoration: none;
    }
    .btn:hover  { transform: translateY(-3px) scale(1.03); }
    .btn:active { transform: translateY(0) scale(.98); }

    .btn-primary {
      background: linear-gradient(135deg, var(--rouge), var(--orange));
      color: var(--blanc);
      box-shadow: 0 6px 20px rgba(232,38,58,.35);
    }
    .btn-secondary {
      background: linear-gradient(135deg, var(--bleu), #2563EB);
      color: var(--blanc);
      box-shadow: 0 6px 20px rgba(26,115,232,.3);
    }
    .btn-success {
      background: linear-gradient(135deg, var(--vert), #16A34A);
      color: var(--blanc);
      box-shadow: 0 6px 20px rgba(34,197,94,.3);
    }
    .btn-admin {
      background: linear-gradient(135deg, #6D28D9, #4C1D95);
      color: var(--blanc);
      box-shadow: 0 6px 20px rgba(109,40,217,.3);
    }

    #btn-participer, #btn-retour {
      width: 100%;
      text-align: center;
    }

    /* ===== FORMULAIRE (#form-section) ===== */
    #form-section { border-color: #bfdbfe; }
    #form-section h2 { color: var(--bleu); }
    #form-section.hidden,
    #success.hidden,
    #admin-section.hidden { display: none; }

    .form-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 16px;
    }
    .form-grid .full { grid-column: 1 / -1; }

    label {
      display: block;
      font-weight: 700;
      font-size: .88rem;
      margin-bottom: 6px;
      color: #374151;
      text-transform: uppercase;
      letter-spacing: .5px;
    }

    input[type="text"],
    input[type="number"],
    input[type="password"],
    select {
      width: 100%;
      padding: 12px 16px;
      border: 2px solid #E5E7EB;
      border-radius: 12px;
      font-family: 'Nunito', sans-serif;
      font-size: 1rem;
      font-weight: 600;
      color: var(--texte);
      background: var(--fond);
      transition: border-color .2s, box-shadow .2s;
      appearance: none;
      -webkit-appearance: none;
    }
    input:focus, select:focus {
      outline: none;
      border-color: var(--bleu);
      box-shadow: 0 0 0 4px rgba(26,115,232,.12);
    }

    .select-wrapper {
      position: relative;
    }
    .select-wrapper::after {
      content: '▾';
      position: absolute;
      right: 14px; top: 50%;
      transform: translateY(-50%);
      pointer-events: none;
      color: var(--bleu);
      font-size: 1.1rem;
    }

    #submit-btn { margin-top: 8px; width: 100%; }

    /* ===== SUCCÈS (#success) ===== */
    #success {
      text-align: center;
      border-color: #bbf7d0;
      background: linear-gradient(145deg, #f0fdf4, #dcfce7);
    }
    #success h2 { color: var(--vert); justify-content: center; font-size: 2rem; }
    .success-icon { font-size: 4rem; margin: 12px 0; animation: pop .5s cubic-bezier(.36,2,.5,1) both; }
    @keyframes pop {
      from { transform: scale(0); }
      to   { transform: scale(1); }
    }
    #success p { font-size: 1.1rem; font-weight: 700; margin-bottom: 24px; color: #166534; }

    /* ===== ADMIN (#admin-section) ===== */
    #admin-section { border-color: #DDD6FE; }
    #admin-section h2 { color: #6D28D9; }

    .admin-login { display: flex; flex-direction: column; gap: 12px; }
    #admin-login-btn { align-self: flex-start; }

    #admin-panel { margin-top: 16px; }
    #admin-panel.hidden { display: none; }

    .stat-badge {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      background: var(--fond);
      border: 2px solid var(--jaune);
      border-radius: 50px;
      padding: 8px 20px;
      font-family: 'Fredoka One', cursive;
      font-size: 1.1rem;
      color: var(--rouge);
      margin-bottom: 20px;
    }

    .admin-row {
      display: flex;
      align-items: center;
      gap: 12px;
      flex-wrap: wrap;
      margin-bottom: 12px;
    }
    .admin-row input { max-width: 180px; }
    #calculate-btn { flex-shrink: 0; }

    #result-display {
      margin-top: 16px;
      padding: 16px 20px;
      border-radius: 14px;
      background: linear-gradient(135deg, #FFF7ED, #FFEDD5);
      border: 2px solid var(--orange);
      font-family: 'Fredoka One', cursive;
      font-size: 1.15rem;
      color: #9A3412;
      display: none;
    }
    #result-display.visible { display: block; }

    /* ===== TABLE PARTICIPANTS ===== */
    #participants-table {
      width: 100%;
      border-collapse: collapse;
      margin-top: 16px;
      font-size: .9rem;
    }
    #participants-table th {
      background: linear-gradient(135deg, var(--bleu), #2563EB);
      color: white;
      padding: 10px 14px;
      text-align: left;
      font-family: 'Fredoka One', cursive;
      font-size: 1rem;
    }
    #participants-table th:first-child { border-radius: 12px 0 0 0; }
    #participants-table th:last-child  { border-radius: 0 12px 0 0; }
    #participants-table td {
      padding: 10px 14px;
      border-bottom: 1px solid #F3F4F6;
      font-weight: 600;
    }
    #participants-table tr:nth-child(even) td { background: #F9FAFB; }
    #participants-table tr:hover td { background: #EFF6FF; }

    /* ===== CONFETTIS ===== */
    .confetti-container {
      position: fixed; inset: 0;
      pointer-events: none;
      overflow: hidden;
      z-index: 999;
    }
    .confetti-piece {
      position: absolute;
      top: -20px;
      width: 10px; height: 14px;
      border-radius: 2px;
      animation: tombConfetti linear forwards;
    }
    @keyframes tombConfetti {
      to { transform: translateY(110vh) rotate(720deg); opacity: 0; }
    }

    /* ===== FOOTER ===== */
    footer {
      text-align: center;
      padding: 20px;
      font-size: .82rem;
      color: #9CA3AF;
      font-weight: 600;
    }

    /* ===== RESPONSIVE ===== */
    @media (max-width: 480px) {
      .form-grid { grid-template-columns: 1fr; }
      .form-grid .full { grid-column: 1; }
      .section { padding: 24px 18px; }
      .admin-row { flex-direction: column; align-items: stretch; }
      .admin-row input { max-width: 100%; }
    }

/* ===== NAVIGATION PAR CLASSE ACTIVE ===== */

/* #home, #form-section, #success : cachés par défaut, visibles avec .active */
#home,
#form-section,
#success {
  display: none;
}

#home.active,
#form-section.active,
#success.active {
  display: block;
}

/* #admin-section toujours visible en bas de page */
#admin-section {
  display: block;
}

/* Panel admin interne : caché tant que .hidden est présent */
#admin-panel.hidden {
  display: none !important;
}
#admin-panel:not(.hidden) {
  display: block;
}