/* ===== Canvas 3D fond (derrière tout) ===== */
#bg3d {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}

/* ===== Hub — écran d'accueil ===== */

/* --- Titre --- */
.home-title {
  font-size: clamp(1.6rem, 6vw, 2.8rem);
  font-weight: 700;
  margin-bottom: 20px;
  background: linear-gradient(120deg, var(--c-grape) 0%, var(--c-bubble) 50%, var(--c-sky) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
  letter-spacing: .02em;
  filter: drop-shadow(0 2px 8px rgba(167,139,250,.25));
}

/* --- Bandeau d'étoiles du jour (récompense douce) --- */
.stars {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  margin: -6px 0 14px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: var(--sh-soft);
  max-width: 92vw;
}
.stars .star {
  font-size: clamp(1.1rem, 3.4vmin, 1.6rem);
  line-height: 1;
  filter: grayscale(1) opacity(.35);
  transform: scale(.92);
  transition: filter .3s ease, transform .3s cubic-bezier(.34,1.56,.64,1);
}
.stars .star.on {
  filter: none;
  transform: scale(1);
}
/* Étoile fraîchement gagnée : petit éclat */
.stars .star.pop {
  animation: star-pop .55s cubic-bezier(.34,1.7,.5,1);
}
@keyframes star-pop {
  0%   { transform: scale(.6) rotate(-18deg); }
  55%  { transform: scale(1.5) rotate(10deg); }
  100% { transform: scale(1) rotate(0deg); }
}
@media (prefers-reduced-motion: reduce) {
  .stars .star { transition: none; }
  .stars .star.pop { animation: none; }
}
@media (max-height: 500px) {
  .stars { margin: 2px 0 6px; padding: 3px 10px; }
}

/* --- Grille de tuiles --- */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 14px;
  width: min(900px, 92vw);
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  padding: 10px 6px;
  /* Hide scrollbar but keep scrolling */
  scrollbar-width: thin;
  scrollbar-color: rgba(167,139,250,.4) transparent;
}
.tiles::-webkit-scrollbar { width: 4px; }
.tiles::-webkit-scrollbar-thumb { background: rgba(167,139,250,.4); border-radius: 4px; }

/* --- Tuile — carte premium glassy --- */
.tile {
  aspect-ratio: 1;
  border: 1.5px solid rgba(255, 255, 255, .65);
  border-radius: var(--r-lg);
  background: rgba(255, 255, 255, .55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: var(--sh-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--c-ink);
  cursor: pointer;

  /* Entrée en cascade : animation fade+rise */
  opacity: 0;
  transform: translateY(18px) scale(.95);
  animation: tile-enter .45s cubic-bezier(.34,1.3,.64,1) forwards;

  /* Hover/press */
  transition: transform .2s cubic-bezier(.34,1.56,.64,1),
              box-shadow .2s ease,
              border-color .2s ease;
}

/* Délais croissants par tuile (nth-child 1–11) */
.tile:nth-child(1)  { animation-delay:  .04s; }
.tile:nth-child(2)  { animation-delay:  .08s; }
.tile:nth-child(3)  { animation-delay:  .12s; }
.tile:nth-child(4)  { animation-delay:  .16s; }
.tile:nth-child(5)  { animation-delay:  .20s; }
.tile:nth-child(6)  { animation-delay:  .24s; }
.tile:nth-child(7)  { animation-delay:  .28s; }
.tile:nth-child(8)  { animation-delay:  .32s; }
.tile:nth-child(9)  { animation-delay:  .36s; }
.tile:nth-child(10) { animation-delay:  .40s; }
.tile:nth-child(11) { animation-delay:  .44s; }
.tile:nth-child(n+12){ animation-delay:  .48s; }

@keyframes tile-enter {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Hover : légère inclinaison + élévation */
.tile:hover {
  transform: rotate(-2deg) scale(1.05);
  box-shadow: var(--sh-pop);
  border-color: rgba(255, 255, 255, .9);
}
/* Press springy */
.tile:active {
  transform: scale(.94) rotate(0deg);
  box-shadow: 0 4px 12px rgba(90,70,160,.15);
}

/* Emoji dans la tuile */
.tile .emoji {
  font-size: clamp(2rem, 5vmin, 3.6rem);
  line-height: 1;
}

/* --- Bouton son flottant --- */
.home-sound {
  position: fixed;
  top: 12px;
  right: 12px;
  background: rgba(255,255,255,.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--c-ink);
  border: 1.5px solid rgba(255,255,255,.9);
  box-shadow: var(--sh-soft);
}
.home-sound:hover {
  background: rgba(255,255,255,.92);
}

/* ===== Paysage tablette ===== */
@media (max-height: 500px) {
  .home-title { margin-bottom: 6px; }
  .tiles {
    gap: 8px;
    max-height: calc(100vh - 80px);
  }
  .tile .emoji { font-size: clamp(1.4rem, 4vmin, 2.4rem); }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  .tile {
    animation: none;
    opacity: 1;
    transform: none;
  }
  .tile:hover  { transform: none; }
  .tile:active { transform: scale(.97); }
}
