:root {
  --encre: #3a1d5c;
  --police: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #d9c4ff;
  font-family: var(--police);
  color: var(--encre);
  user-select: none; -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}
canvas#jeu { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.cache { display: none !important; }

button { font: inherit; color: inherit; border: 0; cursor: pointer; }
button:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

/* --- HUD --- */
#hud {
  position: fixed; left: 0; right: 0; top: 0;
  padding: calc(env(safe-area-inset-top) + 12px) 14px 0;
  display: flex; align-items: flex-start; justify-content: space-between;
  pointer-events: none;
}
#hud > * { pointer-events: auto; }
#score-boite { text-align: center; pointer-events: none; }
#score {
  font-size: 46px; font-weight: 900; line-height: 1;
  color: #fff;
  -webkit-text-stroke: 7px var(--encre);
  paint-order: stroke fill;
  text-shadow: 0 4px 0 rgba(58, 29, 92, 0.35);
  font-variant-numeric: tabular-nums;
  display: inline-block;
}
#score.bump { animation: bump 0.32s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes bump { 0% { transform: scale(1); } 35% { transform: scale(1.22) rotate(-2deg); } 100% { transform: scale(1); } }
#meilleur { font-size: 13px; font-weight: 800; opacity: 0.7; margin-top: 4px; }
#suivant-boite {
  width: 62px; height: 62px; border-radius: 22px;
  background: rgba(255, 255, 255, 0.4);
  box-shadow: inset 0 0 0 2.5px rgba(255, 255, 255, 0.85), 0 4px 0 rgba(58, 29, 92, 0.12);
  text-align: center; font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: .5px;
  padding-top: 4px; pointer-events: none;
}

.rond {
  width: 48px; height: 48px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  box-shadow: inset 0 0 0 2.5px rgba(255, 255, 255, 0.9), 0 4px 0 rgba(58, 29, 92, 0.15);
  display: grid; place-items: center;
  transition: transform .15s;
}
.rond:active { transform: scale(0.88); }
.rond svg { width: 24px; height: 24px; fill: var(--encre); }
.options .rond svg { fill: none; stroke: var(--encre); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.options .rond svg .plein { fill: var(--encre); }
.options .rond .barre { display: none; }
.options .rond.off { opacity: .55; }
.options .rond.off .barre { display: inline; }
.options .rond.off .onde { display: none; }

#b-secousse {
  position: fixed; right: 14px; bottom: calc(env(safe-area-inset-bottom) + 78px);
  width: 58px; height: 58px; border-radius: 20px;
  background: linear-gradient(#ffe57a, #ffb84d);
  box-shadow: inset 0 -4px 0 rgba(150, 70, 0, .25), 0 5px 0 rgba(58, 29, 92, .2);
  display: grid; place-items: center;
  transition: transform .15s, filter .2s;
}
#b-secousse svg { width: 30px; height: 30px; fill: none; stroke: var(--encre); stroke-width: 2.2; stroke-linecap: round; }
#b-secousse .n {
  position: absolute; top: -6px; right: -6px; min-width: 24px; height: 24px; border-radius: 12px;
  background: #ff5c8a; color: #fff; font-weight: 900; font-size: 14px; line-height: 24px;
  box-shadow: 0 0 0 2.5px #fff;
}
#b-secousse:active { transform: scale(.88) rotate(-6deg); }
#b-secousse:disabled { filter: grayscale(1) opacity(.5); cursor: default; }
#b-secousse.bump { animation: secoue .5s; }
@keyframes secoue { 20% { transform: rotate(-14deg) scale(1.15); } 40% { transform: rotate(12deg) scale(1.15); } 60% { transform: rotate(-8deg); } 80% { transform: rotate(5deg); } }

/* --- Toast --- */
#toast {
  z-index: 10;
  position: fixed; left: 50%; top: 26%;
  transform: translate(-50%, -50%) scale(.4);
  opacity: 0; pointer-events: none;
  text-align: center; white-space: nowrap;
  padding: 12px 22px; border-radius: 22px;
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 8px 0 rgba(58, 29, 92, .15), 0 0 0 3px #fff;
  font-weight: 900;
  transition: transform .25s cubic-bezier(.3, 1.8, .5, 1), opacity .2s;
}
#toast.vu { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#toast small { display: block; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; opacity: .7; }
#toast b { font-size: 30px; -webkit-text-stroke: 5px var(--encre); paint-order: stroke fill; }
#toast.petit { font-size: 17px; padding: 8px 16px; top: 20%; }

/* --- Écrans --- */
.ecran {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px;
  opacity: 0; pointer-events: none;
  transition: opacity .3s;
}
.ecran.vu { opacity: 1; pointer-events: auto; }
#menu { background: radial-gradient(ellipse at center, rgba(255, 255, 255, .35), rgba(255, 255, 255, 0) 70%); }
#pause, #fin { background: rgba(70, 30, 110, .35); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }

.logo {
  margin: 0; font-size: clamp(76px, 22vw, 132px); font-weight: 900; letter-spacing: -2px; line-height: 1;
  display: flex;
}
.logo span {
  display: inline-block;
  color: #fff;
  -webkit-text-stroke: 12px var(--encre);
  paint-order: stroke fill;
  text-shadow: 0 8px 0 rgba(58, 29, 92, .3);
  animation: gelee 2.4s ease-in-out infinite;
  transform-origin: 50% 90%;
}
.logo span:nth-child(1) { color: #4fd8ff; animation-delay: 0s; }
.logo span:nth-child(2) { color: #8ef25a; animation-delay: .12s; }
.logo span:nth-child(3) { color: #ff74c0; animation-delay: .24s; }
.logo span:nth-child(4) { color: #ffa94d; animation-delay: .36s; }
.logo span:nth-child(5) { color: #7b6cff; animation-delay: .48s; }
@keyframes gelee {
  0%, 60%, 100% { transform: scale(1, 1) translateY(0); }
  10% { transform: scale(1.18, .8) translateY(0); }
  22% { transform: scale(.88, 1.14) translateY(-14px); }
  34% { transform: scale(1.06, .94) translateY(0); }
  44% { transform: scale(.98, 1.02); }
}
.logo span:active { animation: none; transform: scale(1.3, .7); }

.accroche { font-weight: 800; font-size: 17px; margin: 10px 0 24px; text-align: center; opacity: .85; }
.boutons { display: flex; flex-direction: column; gap: 14px; width: min(320px, 86vw); }

.gros {
  width: 100%;
  padding: 14px 18px 16px; border-radius: 24px;
  font-size: 24px; font-weight: 900; color: #fff;
  -webkit-text-stroke: 4px rgba(58, 29, 92, .75); paint-order: stroke fill;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .14), inset 0 3px 0 rgba(255, 255, 255, .45), 0 6px 0 rgba(58, 29, 92, .22);
  transition: transform .12s;
  display: flex; flex-direction: column; align-items: center; line-height: 1.1;
}
.gros:active { transform: scale(.94, .9); }
.gros small { font-size: 13px; font-weight: 800; -webkit-text-stroke: 0; color: rgba(255, 255, 255, .92); margin-top: 2px; }
.rose { background: linear-gradient(#ff9ad5, #ff5ca8); }
.bleu { background: linear-gradient(#7fe3ff, #4aa8ff); }
.vert { background: linear-gradient(#9ff57a, #3fcf7a); }
.jaune { background: linear-gradient(#ffe57a, #ffb84d); font-size: 21px; white-space: nowrap; }
.gris { background: linear-gradient(#c9b8e8, #9a83c9); }

#collection { font-weight: 800; font-size: 14px; opacity: .75; margin: 22px 0 10px; }
.options { display: flex; gap: 14px; justify-content: center; margin-top: 8px; }

.carte {
  width: min(340px, 90vw);
  background: rgba(255, 255, 255, .88);
  border-radius: 32px;
  padding: 24px 22px;
  box-shadow: 0 0 0 4px #fff, 0 12px 0 rgba(58, 29, 92, .2);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  transform: scale(.7);
  transition: transform .35s cubic-bezier(.3, 1.8, .5, 1);
}
.ecran.vu .carte { transform: scale(1); }
.carte h2 { margin: 0 0 4px; font-size: 28px; font-weight: 900; }
#fin-score {
  font-size: 64px; font-weight: 900; line-height: 1; color: #ffd34d;
  -webkit-text-stroke: 9px var(--encre); paint-order: stroke fill;
}
#fin-record, #fin-palier { font-weight: 800; opacity: .75; }
#fin-palier { margin-bottom: 8px; }
.badge {
  background: #ff5c8a; color: #fff; font-weight: 900; padding: 6px 14px; border-radius: 14px;
  animation: secoue 0.6s 0.3s;
}

/* Version CrazyGames : pas de lien vers l'extérieur */
.portail [data-action="partager"] { display: none; }
#b-secousse.pub .n { background: #3fcf7a; font-size: 11px; }
