/* Attrape l'étoile : une gravure sur linoléum en trois encres sur papier crème */
:root {
  --encre: #14264a;
  --nuit: #14264a;
  --colline: #14264a;
  --papier: #f3e6cc;
  --papier-ombre: #dccaa6;
  --or: #f2b33d;
  --or-fonce: #c98420;
  --corail: #e0482f;
  --texte: #14264a;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: var(--nuit);
  font-family: "Andika", sans-serif;
  color: var(--texte);
  touch-action: none;
  user-select: none; -webkit-user-select: none;
}

canvas#ciel { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.cache { display: none !important; }

/* Écrans */
.ecran {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(16, 39, 44, .45);
  z-index: 10;
}
.ecran.transparent { background: none; pointer-events: none; }

/* Carte en papier : bord déchiré et ombre décalée, pas de verre */
.carte {
  position: relative;
  width: min(420px, 100%);
  background: var(--papier);
  border: 3px solid var(--encre);
  outline: 2px solid var(--papier); outline-offset: -9px;
  padding: 28px 26px 22px;
  text-align: center;
  animation: pose .35s cubic-bezier(.2, 1.4, .4, 1);
}
.carte.large { width: min(640px, 100%); }
.carte::before { content: ""; position: absolute; inset: 6px; border: 1.5px solid var(--encre); pointer-events: none; }
@keyframes pose { from { transform: translateY(20px); opacity: 0; } }

/* Écran titre : une affiche imprimée sur le ciel, sans carte */
.ecran.affiche { background: none; align-items: flex-start; padding-top: max(7vh, 40px); }
.titre { text-align: center; color: var(--papier); max-width: 520px; }
.titre h1 { color: var(--papier); font-size: clamp(54px, 13vw, 96px); text-shadow: 4px 4px 0 var(--corail); }
.titre h1 span { color: var(--or); text-shadow: 4px 4px 0 var(--corail); }
.titre p { font-size: 19px; line-height: 1.4; margin: 18px auto 20px; max-width: 420px; font-weight: 700; }
.titre .petit { opacity: .85; }

h1, h2, .nom { font-family: "Alfa Slab One", serif; font-weight: 400; line-height: .95; letter-spacing: .01em; }
h1 { font-size: clamp(48px, 12vw, 72px); color: var(--encre); }
h1 span { color: var(--corail); }
h2 { font-size: 36px; color: var(--encre); margin-bottom: 10px; }
.carte p { font-size: 17px; line-height: 1.4; margin: 14px 0 18px; font-weight: 600; }
.petit { font-size: 14px !important; opacity: .7; font-weight: 800; margin: 8px 0 !important; }

button { font-family: inherit; cursor: pointer; border: 0; }
.gros {
  display: block; margin: 6px auto 4px;
  background: var(--corail); color: var(--papier);
  font-family: "Alfa Slab One", serif; font-size: 24px; font-weight: 400;
  padding: 12px 44px; border-radius: 3px;
  border: 3px solid var(--encre);
  box-shadow: 4px 4px 0 var(--encre);
  transition: transform .08s;
}
.gros:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--encre); }
.lien { display: block; margin: 10px auto 0; background: none; font-size: 16px; font-weight: 800; color: var(--colline); text-decoration: underline; text-underline-offset: 3px; }

/* HUD */
#hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: max(12px, env(safe-area-inset-top)) 14px 0;
  pointer-events: none;
}
.hud-gauche { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.hud-droite { display: flex; gap: 8px; pointer-events: auto; }
#coeurs { display: flex; gap: 3px; }
#coeurs svg { width: 26px; height: 26px; transition: transform .2s; }
#coeurs svg.perdu { opacity: .25; transform: scale(.8); }
#score {
  font-family: "Alfa Slab One", serif; font-weight: 400; font-size: 30px; color: var(--papier);
  text-shadow: 3px 3px 0 var(--encre); min-width: 2ch;
}
#combo { font-weight: 700; font-size: 17px; color: var(--or); text-shadow: 2px 2px 0 var(--encre); }
#combo.saute { animation: saute .25s; }
@keyframes saute { 50% { transform: scale(1.4) rotate(-6deg); } }
.rond {
  width: 44px; height: 44px; border-radius: 3px;
  background: var(--papier); border: 2.5px solid var(--encre);
  display: grid; place-items: center;
}
.rond svg { width: 22px; height: 22px; }

/* Bandeau de début de nuit */
.bandeau {
  background: var(--papier); padding: 16px 30px 18px; text-align: center;
  border: 3px solid var(--encre); max-width: 92vw;
  animation: bandeau 2.6s ease forwards;
}
.bandeau .nom { font-size: clamp(34px, 9vw, 52px); color: var(--encre); }
#intro-regle { font-weight: 700; font-size: 17px; margin-top: 8px; color: var(--colline); display: flex; align-items: center; justify-content: center; gap: 8px; }
#intro-regle svg { width: 30px; height: 30px; flex: none; }
@keyframes bandeau {
  0% { transform: translateY(-30px); opacity: 0; }
  12% { transform: translateY(0); opacity: 1; }
  80% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(-20px); opacity: 0; }
}

/* Liste des nuits */
#liste-nuits {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px; margin: 16px 0 6px;
}
.nuit {
  position: relative; background: var(--nuit); color: var(--papier);
  border-radius: 2px; padding: 12px 8px 10px; text-align: center;
  border: 2px solid var(--encre); font-weight: 700;
  transition: transform .1s;
}
.nuit:active { transform: translateY(3px); }
.nuit canvas { width: 100%; height: 64px; display: block; }
.nuit .titre-nuit { font-family: "Alfa Slab One", serif; font-size: 17px; margin-top: 4px; }
.nuit .num { font-size: 12px; opacity: .7; }
.nuit .mini-etoiles { display: flex; justify-content: center; gap: 2px; margin-top: 4px; }
.nuit .mini-etoiles svg { width: 18px; height: 18px; }
.nuit.verrou { background: #5a6b8c; opacity: .75; cursor: default; }
.nuit.verrou .titre-nuit::after { content: ""; }
.nuit .cadenas { position: absolute; top: 8px; right: 8px; width: 20px; height: 20px; }
.nuit.sans-fin { background: var(--corail); }

#fin-etoiles { display: flex; justify-content: center; gap: 8px; margin: 6px 0; }
#fin-etoiles svg { width: 58px; height: 58px; }
#fin-etoiles svg.on { animation: tampon .45s cubic-bezier(.2, 1.6, .4, 1) backwards; }
#fin-etoiles svg:nth-child(2) { animation-delay: .2s; transform: translateY(-10px); }
#fin-etoiles svg:nth-child(3) { animation-delay: .4s; }
@keyframes tampon { from { transform: scale(2.4) rotate(-30deg); opacity: 0; } }

@media (max-width: 520px) {
  .ecran.affiche { padding-top: 150px; }
  .carte { padding: 22px 18px 18px; }
  #liste-nuits { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .nuit canvas { height: 52px; }
  #score { font-size: 26px; }
}
