/* Jeu de la balance */

/* ---------- Scène ---------- */
.scene {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#balance {
  width: 100%;
  max-width: 820px;
  height: auto;
  max-height: 58vh;
  overflow: visible;
  touch-action: manipulation;
  user-select: none;
}

/* matières */
#balance .bois { fill: url(#g-bois); }
#balance .veine { fill: none; stroke: var(--bois-fonce); stroke-width: 1; stroke-opacity: .45; }
#balance .ombre-sol { fill: var(--ombre-sol); opacity: .14; }
#balance .laiton-h { fill: url(#g-laiton-h); stroke: var(--laiton-trait); stroke-width: .8; stroke-opacity: .6; }
#balance .poutre { fill: url(#g-laiton); stroke: var(--laiton-trait); stroke-width: 1; stroke-opacity: .7; }
#balance .poutre-reflet { fill: none; stroke: var(--laiton-clair); stroke-width: 1.5; stroke-linecap: round; opacity: .9; }
#balance .embout { fill: url(#g-medaillon); stroke: var(--laiton-trait); stroke-width: 1; stroke-opacity: .7; }
#balance .aiguille { fill: var(--grave); }
#balance .cadran { fill: var(--cadran); stroke: var(--laiton-fonce); stroke-width: 2; }
#balance .trait { stroke: var(--encre-douce); stroke-width: 1.4; stroke-linecap: round; }
#balance .trait-centre { stroke: var(--accent); stroke-width: 3; stroke-linecap: round; }

/* plateaux */
#balance .chaine { fill: none; stroke: var(--laiton-fonce); stroke-width: 2.6; stroke-linecap: round; stroke-dasharray: 0.1 5; }
#balance .anneau { fill: none; stroke: var(--laiton-fonce); stroke-width: 2.5; }
#balance .coupe-fond { fill: var(--laiton-fonce); }
#balance .coupe { fill: url(#g-coupe); stroke: var(--laiton-trait); stroke-width: 1; stroke-opacity: .7; transition: stroke .25s; }
#balance .reflet { fill: none; stroke: var(--laiton-clair); stroke-width: 2.5; stroke-linecap: round; opacity: .8; }
#balance .tige { stroke: var(--laiton-fonce); stroke-width: 3; }
#balance .plaque { fill: var(--surface); stroke: var(--laiton-fonce); stroke-width: 2; transition: stroke .25s, fill .25s; }
#balance .total {
  font-family: var(--police);
  font-weight: 600;
  font-size: 19px;
  text-anchor: middle;
  fill: var(--encre);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
#balance.equilibre .plaque { fill: var(--accent); stroke: var(--accent); }
#balance.equilibre .total { fill: var(--sur-accent); }

#signe {
  font-family: var(--police);
  font-weight: 600;
  font-size: 40px;
  text-anchor: middle;
  fill: var(--encre);
  transition: fill .25s;
}
#balance.equilibre #signe { fill: var(--accent); }

/* médaillon et visage */
#balance .medaillon { fill: url(#g-medaillon); stroke: var(--laiton-trait); stroke-width: 1.2; transition: stroke .25s; }
#balance .medaillon-bord { fill: none; stroke: var(--laiton-fonce); stroke-width: 1; opacity: .55; }
#balance .oeil { fill: var(--grave); }
#balance #yeux { transition: transform .35s cubic-bezier(.3, 1.4, .6, 1); }
#balance #bouche { fill: none; stroke: var(--grave); stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }
#balance .joue { fill: #E58A6A; opacity: 0; transition: opacity .25s; }
#balance.equilibre .joue { opacity: .55; }
#balance.equilibre .medaillon { stroke: var(--accent); stroke-width: 3; }
.cligne { animation: cligne .18s ease-in-out; transform-box: fill-box; transform-origin: center; }
@keyframes cligne { 50% { transform: scaleY(.1); } }

/* chronomètre autour du médaillon */
#balance .chrono-fond, #chrono { display: none; }
#balance.avec-chrono .chrono-fond { display: inline; fill: none; stroke: var(--ligne); stroke-width: 5; }
#balance.avec-chrono #chrono { display: inline; fill: none; stroke: var(--accent); stroke-width: 5; stroke-linecap: round; transition: stroke .3s; }
#balance.presse #chrono { stroke: var(--alerte); }

#onde { fill: none; stroke: var(--accent); stroke-width: 3; opacity: 0; }
.onde-anime { animation: onde .9s ease-out; }
@keyframes onde {
  from { opacity: .8; transform: scale(1); }
  to   { opacity: 0; transform: scale(2.4); }
}

.piece-posee.mobile { cursor: pointer; }
.tombe { animation: tombe .45s cubic-bezier(.3, 1.3, .6, 1) both; }
@keyframes tombe {
  from { transform: translateY(-70px); opacity: 0; }
  50%  { opacity: 1; }
  to   { transform: none; opacity: 1; }
}
.bloque { animation: bloque .3s; }
@keyframes bloque {
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

#confettis * { pointer-events: none; }
#confettis .c1 { fill: var(--accent); }
#confettis .c2 { fill: var(--or); }
#confettis .c3 { fill: var(--encre-douce); }

/* ---------- Réserves de pièces ---------- */
.plateaux {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.plateau {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--ligne);
  border-radius: var(--rayon);
  background: var(--surface-2);
}
.piece-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: clamp(58px, 9vw, 82px);
  padding: 6px 4px 8px;
  border: 1px solid var(--ligne);
  border-radius: 14px;
  background: var(--surface);
  color: var(--encre);
  font: inherit;
  cursor: pointer;
  transition: transform .1s, border-color .15s, opacity .2s;
}
.piece-btn:hover { border-color: var(--encre-douce); }
.piece-btn:active { transform: scale(.94); }
.piece-btn .dessin { display: block; width: 100%; aspect-ratio: 1; max-width: 100%; }
.piece-btn .valeur {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  font-weight: 600;
  font-size: 16px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.piece-btn .pastilles { width: 16px; height: 16px; fill: var(--encre-douce); }
.sans-valeurs .piece-btn .valeur { visibility: hidden; }
.piece-btn[aria-disabled="true"] { opacity: .35; }

/* ---------- Téléphone ---------- */
@media (max-width: 560px) {
  .plateaux { gap: 8px; }
  .plateau { gap: 6px; padding: 7px; }
  .piece-btn { width: calc((100% - 12px) / 3); padding: 4px 2px 6px; border-radius: 12px; }
  .piece-btn .valeur { font-size: 14px; gap: 3px; }
  .piece-btn .pastilles { width: 13px; height: 13px; }
}
