/* Cards arrive from the center of the felt with a little rotation and a soft landing. */
.playing-card.dealing-card {
  animation: card-deal-in 295ms cubic-bezier(.17,.85,.3,1.08) both;
  pointer-events: none;
}
@keyframes card-deal-in {
  0% {
    opacity: 0;
    transform: translate(var(--deal-x),var(--deal-y)) scale(.64) rotate(-13deg);
    box-shadow: 0 22px 20px #07251b30;
  }
  70% {
    opacity: 1;
    transform: translate(0,-7px) scale(1.025) rotate(1.5deg);
  }
  100% {
    opacity: 1;
    transform: translate(0,0) scale(1) rotate(0);
  }
}
@media (prefers-reduced-motion: reduce) {
  .playing-card.dealing-card { animation: none; }
}

/* Keep the rules accessible beside the primary game control. */
.game-buttons { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.rules-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: #1b4238; border: 1px solid #698675; border-radius: 8px;
  color: #e4efdd; font: 800 13px 'DM Sans', sans-serif;
  min-height: 47px; padding: 11px 17px;
}
.rules-btn:hover { background: #285b4b; border-color: #bed99b; }
.rules-btn span { font-size: 17px; color: #d7ee88; }
@media (max-width: 500px) {
  .game-buttons { width: 100%; }
  .game-buttons .main-btn { flex: 1; min-width: 0; }
  .rules-btn { flex-shrink: 0; }
}

/* End-of-game celebration, held on screen until the next match. */
.result-overlay {
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  background: radial-gradient(circle at center, #255a46f5 0%, #092c27fa 76%);
  border: 1px solid #94bf7b; border-radius: 13px;
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: scale(.96); transition: opacity .25s, transform .25s, visibility .25s;
  padding: 20px; text-align: center;
}
.result-overlay.visible { opacity: 1; visibility: visible; transform: scale(1); pointer-events: auto; }
.result-icon { font-size: clamp(50px, 6vw, 72px); line-height: 1.25; filter: drop-shadow(0 7px 14px #081a146b); animation: victory-pop .7s ease-out both; }
.result-overline { color: #d7f28e; font-size: 11px; font-weight: 800; letter-spacing: .28em; margin-top: 13px; }
.result-overlay strong { color: #f0ffb2; font: 900 clamp(37px, 6.5vw, 64px)/1.1 Outfit,sans-serif; letter-spacing: -.045em; margin-top: 8px; text-shadow: 0 5px 21px #031d164f; }
.result-overlay p { color: #daecde; font-size: 13px; line-height: 1.5; margin: 12px 0 24px; }
.result-rematch { background: #d7ee88; border: 0; border-radius: 9px; color: #173a2f; font-size: 14px; font-weight: 800; padding: 15px 25px; box-shadow: 0 5px 0 #79984f; }
.result-rematch:hover { background: #ebffab; }
.result-rematch span { margin-left: 10px; }
.result-overlay.defeat { background: radial-gradient(circle at center,#4d5141f5,#112c28fb 76%); border-color: #8e9f83; }
.result-overlay.defeat .result-overline, .result-overlay.defeat strong { color: #f0eed3; }
.result-overlay.tie { background: radial-gradient(circle at center,#335e5cf5,#092c27fa 76%); }
.result-spark { position: absolute; color: #defc98; font-size: 30px; opacity: .8; animation: sparkle-float 2.4s ease-in-out infinite alternate; pointer-events: none; }
.spark-one { left: 19%; top: 20%; }.spark-two { right: 20%; top: 25%; font-size: 20px; animation-delay: .5s; }.spark-three { left: 26%; bottom: 19%; animation-delay: 1s; }
.result-overlay.defeat .result-spark { opacity: .2; }
@keyframes victory-pop { 0% { transform: scale(.25) rotate(-16deg); opacity: 0; } 65% { transform: scale(1.15) rotate(5deg); opacity: 1; } 100% { transform: scale(1) rotate(0); } }
@keyframes sparkle-float { to { transform: translateY(-15px) rotate(25deg); opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .result-icon,.result-spark { animation: none; } .result-overlay { transition: none; } }

/* Replacement cards travel from the active player's deck to the match. */
.playing-card.flying-card {
  position: fixed;
  z-index: 20;
  margin: 0;
  max-height: none;
  pointer-events: none;
  will-change: transform, opacity;
  box-shadow: 0 15px 27px #001b1670, 0 5px 0 #bdcdbb;
}
.playing-card.landed-card { animation: card-landed 240ms ease-out both; }
@keyframes card-landed {
  0% { transform: scale(1.045); box-shadow: 0 10px 18px #021d1870, 0 0 0 3px #d6ed86; }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) { .playing-card.landed-card { animation: none; } }
