/* The brand chip as a real two-sided clay chip.
 *
 * It flips in once when the app opens (the first thing that moves, 900ms, a spring that settles),
 * and spins when tapped: a toss up, two to three turns, a soft landing with the chip-click sound.
 * Two faces back to back plus a red edge between them, so mid-flip it reads as a chip with
 * thickness instead of a flat sticker going edge-on and vanishing.
 * Reduce Motion: no entrance, and a tap gives a small press instead of a spin. */
.chip3d { width: 30px; height: 30px; flex: none; padding: 0; border: 0; background: none; cursor: pointer; perspective: 360px; border-radius: 50%; -webkit-tap-highlight-color: transparent; }
.chip3d:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.chip-coin { position: relative; display: block; width: 100%; height: 100%; transform-style: preserve-3d; }
.chip-face { position: absolute; inset: 0; width: 100%; height: 100%; display: block; backface-visibility: hidden; transform: translateZ(1.6px); }
.chip-back { transform: rotateY(180deg) translateZ(1.6px); }
.chip-edge { position: absolute; inset: 0; border-radius: 50%; background: #951b2b; transform: translateZ(0); box-shadow: 0 0 0 1px rgba(0, 0, 0, .25) inset; }

.chip-coin.enter { animation: chip-enter 900ms cubic-bezier(.2, .9, .25, 1.15) both; }
@keyframes chip-enter {
  0% { transform: rotateY(-540deg) scale(.4); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: rotateY(0deg) scale(1); opacity: 1; }
}

.chip-coin.toss { animation: chip-toss var(--toss-ms, 950ms) cubic-bezier(.3, .7, .35, 1) both; }
@keyframes chip-toss {
  0% { transform: translateY(0) rotateY(0deg) rotateX(0deg) scale(1); }
  35% { transform: translateY(-14px) rotateY(calc(var(--turns, 2) * 180deg)) rotateX(18deg) scale(1.18); }
  80% { transform: translateY(1px) rotateY(calc(var(--turns, 2) * 360deg)) rotateX(0deg) scale(.96); }
  100% { transform: translateY(0) rotateY(calc(var(--turns, 2) * 360deg)) scale(1); }
}

/* Its shadow on the table: shrinks and fades as the chip rises. A filter on the chip itself would
   flatten its 3D faces (the red edge then painted over the front), so the shadow is its own layer. */
.chip3d::before { content: ''; position: absolute; left: 12%; right: 12%; bottom: -5px; height: 6px; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0, 0, 0, .5), transparent); opacity: 0; pointer-events: none; }
.chip3d.tossing::before { animation: chip-shadow var(--toss-ms, 950ms) cubic-bezier(.3, .7, .35, 1) both; }
@keyframes chip-shadow {
  0% { opacity: .5; transform: scaleX(1); }
  35% { opacity: .15; transform: scaleX(.55); }
  80% { opacity: .55; transform: scaleX(1.05); }
  100% { opacity: 0; transform: scaleX(1); }
}

/* A gold glint that sweeps the face once as it lands. */
.chip3d { position: relative; }
.chip3d::after { content: ''; position: absolute; inset: 0; border-radius: 50%; pointer-events: none; opacity: 0;
  background: linear-gradient(115deg, transparent 35%, rgba(241, 226, 184, .85) 50%, transparent 65%); background-size: 250% 100%; }
.chip3d.glint::after { animation: chip-glint 600ms ease-out 1; }
@keyframes chip-glint { 0% { opacity: 1; background-position: 120% 0; } 100% { opacity: 0; background-position: -60% 0; } }

.chip3d.press .chip-coin { animation: chip-press 180ms ease-out both; }
@keyframes chip-press { 50% { transform: scale(.88); } }

@media (prefers-reduced-motion: reduce) {
  .chip-coin.enter, .chip-coin.toss { animation: none; }
  .chip3d.glint::after { animation: none; }
}
