@font-face {
  font-family: 'Fredoka';
  src: url('polices/fredoka.woff2') format('woff2');
  font-weight: 300 700;
  font-display: swap;
}

:root {
  --velours: #7a0e1c;
  --velours-clair: #a3172b;
  --bordeaux: #8b1426;
  --framboise: #e04a63;
  --sapin: #0c3b2e;
  --sapin-clair: #155c45;
  --rouge: #d62839;
  --vert: #1e7b4f;
  --or: #f4b942;
  --creme: #fff3dc;
  --glacier: #9ad8f2;
  --neige: #fbf8f1;
  --encre: #2b1d0e;
  --texte: #1f2421;
  --doux: #5d6862;
  --carte: #ffffff;
  --rayon: 14px;
  --ronde: 'Fredoka', system-ui, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--texte);
  background:
    radial-gradient(circle, rgb(255 255 255 / .07) 1.5px, transparent 2px) 0 0 / 26px 26px,
    radial-gradient(circle at 20% 0%, var(--velours-clair), transparent 60%),
    radial-gradient(circle at 85% 100%, #5e0a15, transparent 55%),
    var(--velours);
  min-height: 100vh;
  overflow-x: hidden;
}
.page { position: relative; z-index: 1; max-width: 760px; margin: 0 auto; padding: 8px 16px 48px; }
.page.large { max-width: 1180px; }

/* Guirlande : fil sinueux et ampoules (construites par deco.js). */
.guirlande {
  position: relative; z-index: 1; height: 46px; margin: 0 -16px 8px;
  display: flex; justify-content: space-around; align-items: flex-start;
  background: radial-gradient(ellipse 60px 22px at 50% 0, transparent 70%, #2f3b2f 72%, #2f3b2f 78%, transparent 80%) 0 0 / 60px 46px repeat-x;
}
.ampoule {
  width: 12px; height: 18px; margin-top: calc(14px + var(--creux, 0px));
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: var(--teinte); box-shadow: 0 0 10px 2px var(--teinte);
  animation: scintille 2.4s ease-in-out infinite; animation-delay: var(--delai);
  position: relative;
}
.ampoule::before { content: ''; position: absolute; top: -5px; left: 3px; width: 6px; height: 6px; border-radius: 2px; background: #3d463d; }
@keyframes scintille { 50% { opacity: .45; box-shadow: none; } }

/* Neige (construite par deco.js) : discrète, derrière le contenu. */
.neige { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.flocon {
  position: absolute; top: -12px; color: #fff; opacity: var(--opacite); font-size: var(--taille);
  animation: chute var(--duree) linear infinite; animation-delay: var(--delai);
}
@keyframes chute { to { transform: translate(var(--derive), 108vh); } }

.entete { color: var(--neige); text-align: center; margin-bottom: 28px; }
.entete h1 {
  font-family: var(--ronde); font-weight: 650; font-size: clamp(2rem, 6vw, 3.4rem);
  line-height: 1.05; margin: 6px 0 10px; letter-spacing: .01em;
  text-shadow: 0 3px 0 rgb(0 0 0 / .25);
}
.sur-titre { font-family: var(--ronde); color: var(--or); font-size: 1rem; font-weight: 500; margin: 0; }
.entete p { margin: 0 auto; max-width: 60ch; font-size: 1.05rem; }

.carte { background: var(--carte); border-radius: var(--rayon); padding: 20px; margin-bottom: 16px; box-shadow: 0 6px 20px rgb(0 0 0 / .25); }
.carte h2 { margin-top: 0; font-family: var(--ronde); font-weight: 600; font-size: 1.35rem; }
label { display: block; font-weight: 600; margin: 12px 0 4px; }
input { width: 100%; padding: 10px 12px; border: 1px solid #c9d0cc; border-radius: 8px; font: inherit; }
button, .bouton {
  font: inherit; font-family: var(--ronde); font-weight: 600; font-size: 1.05rem; border: 0; border-radius: 999px; padding: 10px 22px;
  background: var(--rouge); color: #fff; cursor: pointer; margin-top: 16px;
}
button:focus-visible, input:focus-visible { outline: 3px solid var(--or); outline-offset: 2px; }
button:disabled { opacity: .5; cursor: default; }
.bouton-discret { background: transparent; color: var(--doux); text-decoration: underline; padding: 4px; font-family: inherit; font-weight: 600; font-size: 1rem; }
.retour { margin: 12px 0 0; padding: 10px 12px; border-radius: 8px; background: #e7f3ec; }
.retour.erreur, .erreur { background: #fbe9ea; color: var(--rouge); }
.regles li { margin-bottom: 6px; }

/* ---- La grille : un calendrier en carton, cases de tailles et couleurs variées ---- */
.grille {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  grid-auto-rows: 100px; grid-auto-flow: dense;
  padding: 14px; border-radius: 22px;
  background: rgb(60 5 14 / .55);
  border: 3px solid var(--or);
  box-shadow: 0 0 0 6px rgb(244 185 66 / .18), 0 16px 34px rgb(0 0 0 / .4);
}
@media (min-width: 900px) {
  .grille { grid-template-columns: repeat(6, 1fr); grid-auto-rows: 150px; gap: 16px; padding: 20px; }
}
.case {
  --fond: var(--rouge); --encre-case: #fff; --ruban: var(--or);
  margin: 0; padding: 0; border-radius: 14px; position: relative; overflow: hidden;
  background: var(--fond); color: var(--encre-case);
  border: 0; box-shadow: inset 0 -5px 0 rgb(0 0 0 / .18), 0 3px 0 rgb(0 0 0 / .25);
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s ease;
}
.case.large { grid-column: span 2; }
.case.haute { grid-row: span 2; }
.case.c-rouge { --fond: var(--rouge); --encre-case: #fff; --ruban: var(--or); }
.case.c-bordeaux { --fond: var(--bordeaux); --encre-case: #fff; --ruban: #fff; }
.case.c-creme { --fond: var(--creme); --encre-case: var(--bordeaux); --ruban: var(--rouge); }
.case.c-framboise { --fond: var(--framboise); --encre-case: #fff; --ruban: var(--creme); }
.case.c-or { --fond: var(--or); --encre-case: var(--bordeaux); --ruban: var(--vert); }
/* Ruban croisé des cases encore emballées. */
.case.a_venir::before, .case.aujourdhui::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(var(--ruban), var(--ruban)) 28% 0 / 12px 100% no-repeat,
    linear-gradient(var(--ruban), var(--ruban)) 0 30% / 100% 12px no-repeat;
  opacity: .9;
}
.case .numero {
  position: relative; font-family: var(--ronde); font-weight: 700;
  font-size: clamp(2rem, 4.2vw, 3.6rem); line-height: 1;
  text-shadow: 0 2px 0 rgb(0 0 0 / .15);
}
.case .deco { position: absolute; right: 8px; bottom: 6px; font-size: clamp(1.3rem, 2.4vw, 2.1rem); line-height: 1; }
.case.large .deco, .case.haute .deco { font-size: clamp(1.6rem, 3vw, 2.8rem); }
.case.a_venir .cadenas { position: absolute; top: 6px; right: 8px; font-size: .9rem; opacity: .85; }
.case.aujourdhui { box-shadow: 0 0 0 4px var(--or), 0 0 24px 6px rgb(244 185 66 / .6); z-index: 1; animation: sautille 2.2s ease-in-out infinite; cursor: pointer; }
.case.aujourdhui .etiquette {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%); white-space: nowrap;
  background: #fff; color: var(--rouge); font-family: var(--ronde); font-weight: 600;
  font-size: .85rem; padding: 2px 10px; border-radius: 999px; box-shadow: 0 2px 0 rgb(0 0 0 / .2);
}
.case.aujourdhui:hover { transform: scale(1.03); }
@keyframes sautille { 0%, 100% { transform: rotate(0); } 8% { transform: rotate(-2deg); } 16% { transform: rotate(2deg); } 24% { transform: rotate(0); } }
/* Case ouverte : papier défait, le résultat s'affiche. */
.case.grattee {
  background: var(--neige); color: var(--encre); cursor: pointer;
  box-shadow: inset 0 0 0 3px rgb(0 0 0 / .08);
  background-image: radial-gradient(circle, rgb(214 40 57 / .12) 2px, transparent 2.5px);
  background-size: 18px 18px;
}
.case.grattee .numero { font-size: clamp(1.4rem, 2.6vw, 2.2rem); position: absolute; top: 8px; left: 12px; }
.case.grattee .icone { font-size: clamp(2rem, 4vw, 3.4rem); }
/* Les cases à venir sont des boutons désactivés : elles gardent leurs couleurs. */
.case:disabled { opacity: 1; cursor: default; }
.case.manquee, .case.manquee:disabled { filter: grayscale(.85) brightness(.75); opacity: .55; }
.case.manquee .deco { display: none; }

dialog { border: 0; border-radius: var(--rayon); padding: 22px; width: min(92vw, 560px); }
dialog h2 { font-family: var(--ronde); font-weight: 600; margin-top: 0; }
dialog::backdrop { background: rgb(0 0 0 / .6); }
.carte-grattage { position: relative; height: clamp(220px, 34vh, 320px); border-radius: 12px; overflow: hidden; background: var(--neige); }
.dessous { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 12px; }
.dessous h3 { margin: 0 0 6px; font-family: var(--ronde); font-size: 1.8rem; }
.dessous img { max-height: 110px; max-width: 100%; margin-top: 6px; border-radius: 8px; }
.couche { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; transition: opacity .6s; }
.couche.efface { opacity: 0; pointer-events: none; }
.gains { margin-top: 24px; }
.gains li { margin-bottom: 6px; }
.onglets { display: flex; gap: 8px; margin-bottom: 8px; }
.onglets button { flex: 1; margin-top: 0; background: transparent; color: var(--texte); border: 2px solid #c9d0cc; }
.onglets button[aria-selected="true"] { background: var(--rouge); color: var(--neige); border-color: var(--rouge); }
.aide { font-size: .85rem; color: var(--doux); margin: 4px 0 0; }
.pied { text-align: center; margin-top: 24px; }
.pied .bouton-discret { color: var(--neige); }

.confetti { position: fixed; top: -10px; width: 8px; height: 14px; z-index: 1000; animation: tombe 2.4s linear forwards; }
@keyframes tombe { to { transform: translateY(105vh) rotate(720deg); } }
@media (prefers-reduced-motion: reduce) {
  .case.aujourdhui, .ampoule { animation: none; }
  .neige, .confetti { display: none; }
}
@media (max-width: 600px) {
  .ampoule:nth-child(even) { display: none; }
  .case.aujourdhui .etiquette { font-size: .75rem; padding: 1px 8px; }
}
