/* ========================== RESET ========================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --c0: #ff3030; /* v21 : rouge franc, distinct du rose */
  --c1: #ffb43d;
  --c2: #ffe14a;
  --c3: #5cd6a0;
  --c4: #5db9ff;
}
html, body { width: 100%; height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  /* v36 : thème lagon tropical — turquoise dominant, reflets sable clair */
  background: linear-gradient(180deg,
    #8fe5e2 0%,       /* turquoise surface (ciel) */
    #5bcad0 25%,      /* turquoise moyen */
    #2fa6b8 60%,      /* eau profonde mais claire */
    #1c6f8a 100%      /* fond marin */
  );
  color: #062a3a;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  overscroll-behavior: none;
  position: relative;
  overflow-x: hidden;
}

/* ========================== BULLES ANIMÉES ==========================
   Bulles qui montent du fond vers la surface, en boucle, en arrière-plan.
   Placées sur body::before pour pas interférer avec le contenu. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    /* Petites bulles bien visibles — opacité haute sur fond turquoise clair */
    radial-gradient(circle at 8% 18%, rgba(255,255,255,0.95) 0px, transparent 5px),
    radial-gradient(circle at 18% 22%, rgba(255,255,255,0.85) 0px, transparent 3px),
    radial-gradient(circle at 28% 14%, rgba(255,255,255,0.90) 0px, transparent 4px),
    radial-gradient(circle at 42% 26%, rgba(255,255,255,0.80) 0px, transparent 3px),
    radial-gradient(circle at 55% 12%, rgba(255,255,255,0.85) 0px, transparent 4px),
    radial-gradient(circle at 68% 22%, rgba(255,255,255,0.92) 0px, transparent 5px),
    radial-gradient(circle at 82% 16%, rgba(255,255,255,0.88) 0px, transparent 4px),
    radial-gradient(circle at 92% 28%, rgba(255,255,255,0.82) 0px, transparent 3px),
    /* Mid-band */
    radial-gradient(circle at 12% 48%, rgba(255,255,255,0.78) 0px, transparent 4px),
    radial-gradient(circle at 35% 55%, rgba(255,255,255,0.85) 0px, transparent 5px),
    radial-gradient(circle at 60% 50%, rgba(255,255,255,0.80) 0px, transparent 3px),
    radial-gradient(circle at 88% 58%, rgba(255,255,255,0.90) 0px, transparent 4px),
    /* Bottom */
    radial-gradient(circle at 15% 78%, rgba(255,255,255,0.88) 0px, transparent 5px),
    radial-gradient(circle at 38% 88%, rgba(255,255,255,0.82) 0px, transparent 3px),
    radial-gradient(circle at 58% 82%, rgba(255,255,255,0.90) 0px, transparent 4px),
    radial-gradient(circle at 78% 92%, rgba(255,255,255,0.85) 0px, transparent 5px),
    radial-gradient(circle at 95% 78%, rgba(255,255,255,0.78) 0px, transparent 3px),
    /* Bulles plus grosses pour donner de la profondeur */
    radial-gradient(circle at 25% 35%, rgba(255,255,255,0.65) 0px, transparent 12px),
    radial-gradient(circle at 72% 42%, rgba(255,255,255,0.55) 0px, transparent 14px),
    radial-gradient(circle at 48% 68%, rgba(255,255,255,0.60) 0px, transparent 11px),
    /* Très grosses bulles fantômes (effet profondeur) */
    radial-gradient(circle at 8% 70%, rgba(255,255,255,0.30) 0px, transparent 22px),
    radial-gradient(circle at 88% 8%, rgba(255,255,255,0.28) 0px, transparent 20px),
    radial-gradient(circle at 50% 50%, rgba(255,255,255,0.22) 0px, transparent 26px);
  animation: bubbles 14s linear infinite;
}
@keyframes bubbles {
  0%   { transform: translateY(0)    scale(1);    opacity: 0.9; }
  50%  { opacity: 1; }
  100% { transform: translateY(-100vh) scale(1.15); opacity: 0; }
}
button { font-family: inherit; cursor: pointer; }

/* ========================== SCREENS ========================== */
.screen {
  position: fixed; inset: 0;
  display: none;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  z-index: 1;
}
.screen.active { display: flex; }

/* ========================== HOME ========================== */
#home { align-items: center; justify-content: flex-start; padding: 16px 20px; overflow-y: auto; height: 100vh; }
.home-inner { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 12px; align-items: stretch; padding: 8px 0 80px; }
.logo { text-align: center; }
.logo-starfish {
  width: 104px; height: 104px;
  display: block;
  margin: 0 auto;
  border-radius: 28px;
  /* Lueur aquatique autour de l'icône */
  filter: drop-shadow(0 0 24px rgba(255,112,149,0.55))
          drop-shadow(0 6px 18px rgba(0,30,60,0.5));
  /* Petite vague en bas, comme flottant sur l'eau */
  animation: float 4s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0)    rotate(-1deg); }
  50%      { transform: translateY(-6px) rotate(1deg);  }
}
.logo h1 {
  font-size: 34px;
  font-weight: 900;
  letter-spacing: -1.5px;
  /* Dégradé corail → orange (couleur de marque Mer Pops) */
  background: linear-gradient(135deg, #ff8db8 0%, #ff7095 50%, #ffa76b 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-top: 10px;
  text-shadow: 0 0 24px rgba(255,112,149,0.25);
}
.tagline {
  color: #0e4a5c;
  font-size: 13px;
  margin-top: 6px;
  font-style: italic;
  opacity: 0.9;
  text-shadow: 0 1px 2px rgba(255,255,255,0.4);
}

.card {
  /* Effet "vitre" lagon : fond blanc translucide + bordure cyan clair */
  background: linear-gradient(180deg, rgba(255,255,255,0.45) 0%, rgba(255,255,255,0.25) 100%);
  border: 1px solid rgba(255,255,255,0.55);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 20px rgba(0,40,60,0.18);
}
.lbl { font-size: 12px; color: #0e4a5c; text-transform: uppercase; letter-spacing: 1px; font-weight: 700; opacity: 0.75; }

/* ============== Player list ============== */
.player-list { display: flex; flex-direction: column; gap: 6px; }
.player-list.picker .picker-empty { text-align: center; padding: 8px 0; }
.player-list.focus { gap: 0; }
.player-focus {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, rgba(255,107,166,0.10), rgba(255,167,107,0.06));
  border: 1px solid rgba(255,107,166,0.35);
  border-radius: 12px;
  padding: 14px 14px;
}
.player-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff6ba6, #ffa76b);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  color: #1a1228;
  flex-shrink: 0;
  box-shadow: 0 0 14px rgba(255,107,166,0.35);
}
.player-meta { flex: 1; min-width: 0; }
.player-name-big {
  font-size: 18px;
  font-weight: 800;
  color: #062a3a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-sub {
  font-size: 12px;
  color: #1c6f8a;
  margin-top: 2px;
}
.player-focus .switch-btn {
  flex-shrink: 0;
  padding: 8px 14px;
  font-size: 12px;
}
.player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,0.30);
  border: 1px solid rgba(255,255,255,0.40);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.player-row:hover { background: rgba(255,255,255,0.50); }
.player-row .name { font-weight: 600; font-size: 15px; color: #062a3a; }

/* ============== Leaderboard ============== */
.leaderboard-list { display: flex; flex-direction: column; gap: 4px; }
.lb-row {
  display: grid;
  grid-template-columns: 28px 1fr auto auto;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.30);
  border: 1px solid rgba(255,255,255,0.40);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 14px;
  color: #062a3a;
}
.lb-row.is-current { border-color: #ff6ba6; background: rgba(255,107,166,0.18); }
.lb-row .lb-rank {
  font-weight: 800;
  color: #1c6f8a;
  font-size: 14px;
  text-align: center;
}
.lb-row.top1 .lb-rank { color: #c98900; }
.lb-row.top2 .lb-rank { color: #6b7884; }
.lb-row.top3 .lb-rank { color: #9c5a1a; }
.lb-row .lb-name { font-weight: 600; color: #062a3a; }
.lb-row .lb-levels {
  font-size: 11px;
  color: #1c6f8a;
  background: rgba(255,255,255,0.45);
  padding: 2px 8px;
  border-radius: 8px;
}
.lb-row .lb-time {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: #c8530a;
  font-size: 13px;
}
.lb-empty {
  text-align: center;
  color: #1c6f8a;
  font-size: 13px;
  padding: 8px 0;
}

.player-row .badge {
  font-size: 11px;
  color: #c8530a;
  background: rgba(255,167,107,0.30);
  padding: 2px 8px;
  border-radius: 8px;
}
.player-row .del {
  background: transparent;
  border: none;
  color: #1c6f8a;
  font-size: 18px;
  padding: 4px 8px;
  cursor: pointer;
  margin-left: 4px;
}
.player-row .del:hover { color: #d92d4d; }

/* ============== Stats ============== */
.stats-row { display: flex; gap: 10px; }
.stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255,255,255,0.35);
  border-radius: 10px;
  padding: 10px 6px;
  gap: 2px;
}
.stat-val { font-size: 22px; font-weight: 800; color: #c8530a; }
.stat-lbl { font-size: 11px; color: #1c6f8a; text-align: center; }

/* ============== Levels list ============== */
.levels-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
}
.level-tile {
  background: rgba(255,255,255,0.35);
  border: 1px solid rgba(255,255,255,0.45);
  border-radius: 10px;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s, background 0.15s;
  position: relative;
  min-height: 64px;
}
.level-tile.more {
  background: rgba(255,167,107,0.25);
  border-color: rgba(255,167,107,0.50);
  color: #c8530a;
}
.level-tile.more .lvl-num {
  font-size: 22px;
  font-weight: 800;
}
.level-tile:hover:not(.locked) { background: rgba(255,255,255,0.55); border-color: rgba(255,255,255,0.65); }
.level-tile:active:not(.locked) { transform: scale(0.95); }
.level-tile.locked { opacity: 0.4; cursor: not-allowed; filter: grayscale(0.5); }
.level-tile .lvl-num { font-size: 18px; font-weight: 800; color: #062a3a; }
.level-tile .lvl-score {
  font-size: 11px;
  color: #c8530a;
  background: rgba(255,167,107,0.30);
  padding: 1px 6px;
  border-radius: 6px;
}
.level-tile .lvl-done {
  position: absolute;
  top: 4px; right: 4px;
  color: #5cd6a0;
  font-size: 14px;
  font-weight: 700;
}
.level-tile.next { border-color: #ff6ba6; box-shadow: 0 0 0 2px rgba(255,107,166,0.2); }

/* ============== Buttons ============== */
.btn {
  border: none; border-radius: 12px; padding: 14px 18px;
  font-size: 16px; font-weight: 700;
  transition: transform 0.1s, opacity 0.2s, box-shadow 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, #ff8c5b 0%, #ff6ba6 100%); color: #fff; box-shadow: 0 4px 16px rgba(255,107,166,0.35); }
.btn.primary:hover { box-shadow: 0 6px 22px rgba(255,107,166,0.50); }
.btn.ghost { background: rgba(255,255,255,0.30); color: #062a3a; border: 1px solid rgba(255,255,255,0.50); }
.btn.ghost:hover { background: rgba(255,255,255,0.50); border-color: rgba(255,255,255,0.70); }
.btn.ghost.small { padding: 8px 12px; font-size: 13px; align-self: flex-start; }
.btn.ghost.small:hover { color: #062a3a; }

/* ============== How-to ============== */
.how-to {
  background: rgba(255,255,255,0.30);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.6;
  color: #062a3a;
  border: 1px solid rgba(255,255,255,0.40);
}
.how-to summary {
  cursor: pointer;
  font-weight: 700;
  color: #c8530a;
  padding: 2px 0;
  user-select: none;
}
.how-to summary:hover { color: #d92d4d; }
.how-to ol { padding-left: 20px; margin-top: 8px; }
.how-to li { margin-bottom: 3px; }
.how-to b { color: #c8530a; }

/* ========================== GAME ========================== */
#game { background: linear-gradient(180deg, #8fe5e2 0%, #5bcad0 35%, #2fa6b8 100%); overflow-y: auto; color: #062a3a; }
.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  font-size: 15px;
  color: #062a3a;
}
.icon-btn, .hud-restart {
  background: rgba(255,255,255,0.45);
  border: 1px solid rgba(255,255,255,0.55);
  color: #062a3a;
  width: 36px; height: 36px;
  border-radius: 10px;
  font-size: 20px;
  display: flex; align-items: center; justify-content: center;
}
.hud-lvl { font-weight: 800; font-size: 17px; color: #062a3a; text-shadow: 0 1px 2px rgba(255,255,255,0.5); }

.board {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  min-height: 0;
}
.grid {
  display: grid;
  width: 100%;
  max-width: 280px;
  aspect-ratio: 7 / 8;
  gap: 2px;
  background: rgba(255,255,255,0.20);
  border: 2px solid rgba(255,255,255,0.50);
  border-radius: 14px;
  padding: 5px;
  position: relative;
  z-index: 1;
  box-shadow: 0 6px 24px rgba(0,40,60,0.25);
}
.cell {
  background: rgba(255,255,255,0.30);
  border-radius: 10px;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  transition: background 0.2s, transform 0.25s, opacity 0.25s;
}
.cell.has-block {
  border: 1px solid rgba(255,255,255,0.25);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.18), 0 2px 6px rgba(0,40,60,0.25);
}
.cell.popping {
  transform: scale(1.3);
  opacity: 0;
  transition: transform 0.2s ease-out, opacity 0.2s ease-in;
}
.cell.just-popped {
  animation: popBurst 0.22s ease-out;
}
.cell.falling { transition: transform 0.25s ease-in; }
@keyframes popBurst {
  0%   { transform: scale(1); filter: brightness(1.6); }
  60%  { transform: scale(1.25); filter: brightness(2); }
  100% { transform: scale(1); filter: brightness(1); }
}

/* Couleurs des blocs (6 couleurs mesurées sur la vidéo Mer Pops) */
.cell.c0 { background: #ff3030; }   /* rouge (v21 : plus franc, distinct du rose) */
.cell.c1 { background: #ff9933; }   /* orange */
.cell.c2 { background: #ffd93d; }   /* jaune */
.cell.c3 { background: #5cd6a0; }   /* vert */
.cell.c4 { background: #5b8cff; }   /* bleu */
.cell.c5 { background: #9b59ff; }   /* violet */
.cell.c6 { background: #ff70d8; }   /* rose (v21 : magenta distinct) */

/* Shots layer = effets visuels par-dessus la grille */
.shots-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.shots-layer-inner {
  width: 100%;
  max-width: 280px;
  aspect-ratio: 7 / 9;
  position: relative;
}
.shot {
  position: absolute;
  width: 14%;
  height: 6%;
  border-radius: 50%;
  filter: blur(2px);
  animation: shootUp 0.4s ease-out forwards;
}
@keyframes shootUp {
  0%   { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-1500%) scale(0.3); opacity: 0; }
}
/* Traînées de tir entre zone et bloc */
.shot-trail {
  position: absolute;
  pointer-events: none;
  z-index: 5;
  width: 8px;
  height: 40px;
  border-radius: 50%;
  filter: blur(4px);
  animation: trailUp 0.35s ease-out forwards;
}
@keyframes trailUp {
  0%   { opacity: 1; transform: translateY(0) scaleY(1); }
  100% { opacity: 0; transform: translateY(-80px) scaleY(0.3); }
}
.splash {
  position: absolute;
  width: 22%;
  height: 18%;
  border-radius: 50%;
  animation: splash 0.3s ease-out forwards;
  pointer-events: none;
}
@keyframes splash {
  0%   { transform: scale(0.5); opacity: 0.9; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* ========================== SLOTS (zone de tir) ========================== */
.slots-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  max-width: 320px;
  margin: 4px auto;
  width: 100%;
}
.slot {
  width: 46px;
  height: 46px;
  background: rgba(255,255,255,0.30);
  border: 2px dashed rgba(255,255,255,0.65);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  transition: all 0.2s;
  flex-shrink: 0;
}
.slot.empty::before {
  content: '+';
  color: rgba(6,42,58,0.55);
  font-size: 24px;
  font-weight: 300;
}
.slot.filled {
  background: rgba(255,255,255,0.45);
  border-style: solid;
  border-width: 3px;
}
.slot.filled .starfish-svg { width: 90%; height: 90%; }
.zone-ammo {
  position: absolute;
  bottom: -4px; right: -4px;
  min-width: 20px; height: 20px;
  padding: 0 5px;
  background: rgba(0,0,0,0.85);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid rgba(255,255,255,0.3);
  line-height: 1;
  z-index: 2;
}
.slot.firing .starfish-svg { animation: recoil 0.2s ease-out; }
.slot.available {
  border-color: rgba(255, 107, 166, 0.7);
  background: rgba(255, 107, 166, 0.15);
  cursor: pointer;
  animation: slotPulse 1.5s infinite ease-in-out;
}
.slot.available:active { transform: scale(0.95); }
@keyframes slotPulse {
  0%, 100% { border-color: rgba(255, 107, 166, 0.3); }
  50% { border-color: rgba(255, 107, 166, 0.8); }
}
@keyframes recoil {
  0% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
  100% { transform: translateY(0); }
}

/* ========================== STOCK ========================== */
.stock-wrap {
  padding: 6px 16px 16px;
  max-width: 320px;
  margin: 0 auto;
  width: 100%;
}
.stock-label {
  font-size: 12px;
  color: #062a3a;
  margin-bottom: 6px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
  opacity: 0.75;
}
.stock {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(var(--stock-rows, 5), 1fr);
  grid-auto-flow: column dense; /* v19 : remplir COLONNE par colonne (5 colonnes empilées), pas row-major */
  gap: 6px;
  background: rgba(255,255,255,0.30);
  border: 1px solid rgba(255,255,255,0.45);
  border-radius: 12px;
  padding: 8px;
  min-height: 60px;
  align-items: center;
  justify-items: center;
  overflow-y: auto;
  max-height: 50vh;
}
/* v19 : indicateur de rangée cliquable (la 1ère rangée de chaque colonne = top) */
.starfish-wrap.stock-slot.clickable {
  position: relative;
}
.starfish-wrap.stock-slot.clickable::before {
  content: "↑";
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  font-weight: bold;
  color: #ffd700;
  text-shadow: 0 0 6px rgba(255, 215, 0, 0.8);
  animation: bounce-up 1s infinite ease-in-out;
  pointer-events: none;
  z-index: 5;
}
@keyframes bounce-up {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50%      { transform: translateX(-50%) translateY(-4px); }
}
.starfish-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 1;
  position: relative;
}
.starfish-svg {
  width: 100%;
  height: 100%;
  display: block;
}
.starfish-wrap.stock-slot {
  border-radius: 50%;
  transition: transform 0.1s, box-shadow 0.15s, opacity 0.2s;
  background: rgba(255,255,255,0.30);
}
.starfish-wrap.stock-slot.clickable {
  cursor: pointer;
}
.starfish-wrap.stock-slot.clickable:not(.empty):hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.starfish-wrap.stock-slot.clickable:not(.empty):active {
  transform: translateY(0) scale(0.95);
}
.starfish-wrap.stock-slot.queued {
  opacity: 0.75; /* v20 : on voit encore la couleur, juste un peu atténué */
  filter: brightness(0.9) saturate(0.85);
  cursor: default;
}
.starfish-wrap.stock-slot.queued .starfish-ammo {
  opacity: 0.7;
}
.starfish-wrap.stock-slot.queued::after {
  content: "⏳";
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 10px;
  opacity: 0.5;
  pointer-events: none;
  z-index: 3;
}
.starfish-wrap.stock-slot.empty {
  opacity: 0.25;
  cursor: default;
  border: 2px dashed rgba(6,42,58,0.25);
  background: transparent;
}
/* Mystery = étoile de mer grise avec ? */
.starfish-wrap.stock-slot.mystery {
  background: rgba(120, 120, 140, 0.4);
  filter: grayscale(0.6);
}
.starfish-wrap.flash-error {
  animation: stockShake 0.4s;
}
@keyframes stockShake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}
/* Compteur munitions sur la étoile de mer du stock */
.starfish-ammo {
  position: absolute;
  bottom: -2px; right: -2px;
  min-width: 22px; height: 22px;
  padding: 0 5px;
  background: rgba(0,0,0,0.85);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid rgba(255,255,255,0.3);
  line-height: 1;
  z-index: 2;
}
.starfish-wrap.locked { opacity: 0.25; filter: grayscale(0.8); }
.starfish-wrap.next { animation: pulse 1.2s infinite ease-in-out; cursor: default; }
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* ========================== WIN ========================== */
#win { align-items: center; justify-content: center; padding: 24px; }
.win-inner { text-align: center; max-width: 360px; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.win-burst { font-size: 72px; animation: bounce 0.6s ease-out; }
@keyframes bounce {
  0%   { transform: scale(0); }
  60%  { transform: scale(1.2); }
  100% { transform: scale(1); }
}
#win h2 { font-size: 26px; color: #062a3a; }
#win-msg { color: #1c6f8a; font-size: 15px; }
.score-display {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  background: rgba(255,167,107,0.30);
  border: 1px solid rgba(255,167,107,0.50);
  border-radius: 14px;
  padding: 12px 20px;
}
.score-val { font-size: 36px; font-weight: 800; color: #c8530a; }
.score-lbl { font-size: 14px; color: #062a3a; text-transform: uppercase; letter-spacing: 1px; }

/* ========================== OVERLAY ========================== */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,40,60,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.overlay.hidden { display: none; }
.overlay-inner {
  background: linear-gradient(180deg, #ffffff 0%, #f0fafc 100%);
  color: #062a3a;
  border: 1px solid rgba(255,255,255,0.70);
  border-radius: 16px;
  padding: 28px 24px;
  max-width: 320px;
  width: 90%;
  text-align: center;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 12px 40px rgba(0,40,60,0.35);
}

/* ========================== Responsive ========================== */
@media (max-height: 700px) {
  .logo-starfish { font-size: 48px; }
  .logo h1 { font-size: 32px; }
  .how-to { display: none; }
}

/* ========================== v14 : Drag-swap stock ========================== */
.starfish-wrap.stock-slot.dragging {
  opacity: 0.3;
  transform: scale(0.9);
}
.starfish-wrap.stock-slot.drag-over {
  outline: 2px dashed #ff6ba6;
  outline-offset: 2px;
  background: rgba(255, 107, 166, 0.15);
}
.slot.drag-target {
  outline: 2px dashed #ffa76b;
  outline-offset: 2px;
  background: rgba(255, 167, 107, 0.15);
}

/* ========================== v14 : Progress indicator sur la grille ========================== */
.grid-progress {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 700;
  color: #ffa76b;
  background: rgba(0,0,0,0.5);
  padding: 2px 8px;
  border-radius: 8px;
  letter-spacing: 0.5px;
  white-space: nowrap;
  z-index: 3;
}
.board { position: relative; }

/* ========================== v14 : Grille plus petite pour accommoder stock dynamique ========================== */
@media (max-height: 900px) {
  .grid { max-width: 260px; }
  .slots-row { max-width: 260px; }
  .stock-wrap { max-width: 260px; }
}
@media (max-height: 700px) {
  .grid { max-width: 240px; }
  .slots-row { max-width: 240px; }
  .stock-wrap { max-width: 240px; }
}

/* ========================== v15 : Projectile de tir ========================== */
.projectile {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 10;
  left: var(--from-x);
  top: var(--from-y);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 12px currentColor, 0 0 24px currentColor;
  opacity: 0;
  transition: none;
}
.projectile.flying {
  animation: projectileFly 0.2s cubic-bezier(0.4, 0, 0.6, 1) forwards;
}
.projectile.c0 { background: #ff3030; color: #ff3030; }
.projectile.c1 { background: #ff9933; color: #ff9933; }
.projectile.c2 { background: #ffd93d; color: #ffd93d; }
.projectile.c3 { background: #5cd6a0; color: #5cd6a0; }
.projectile.c4 { background: #5b8cff; color: #5b8cff; }
.projectile.c5 { background: #9b59ff; color: #9b59ff; }
.projectile.c6 { background: #ff70d8; color: #ff70d8; }
@keyframes projectileFly {
  0% {
    left: var(--from-x);
    top: var(--from-y);
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.2);
  }
  100% {
    left: var(--to-x);
    top: var(--to-y);
    opacity: 0.8;
    transform: translate(-50%, -50%) scale(0.7);
  }
}

/* ========================== v15 : Animation chute colonne ========================== */
.cell.falling {
  animation: cellFall 0.25s ease-in;
}
@keyframes cellFall {
  0%   { transform: translateY(-100%); opacity: 0.3; }
  60%  { transform: translateY(0%); opacity: 1; }
  100% { transform: translateY(0%); opacity: 1; }
}