.hfcard {
  position: relative;
  width: 48px;
  height: 74px;
  border-radius: 7px;
  background: #fbf3e2;
  color: #1a1206;
  border: 1px solid #b8a47f;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .45);
  display: grid;
  place-items: center;
  font-family: var(--hanafuda);
  overflow: hidden;
  opacity: 0;
  transform: translateY(6px);
}
.hfcard.in { opacity: 1; transform: none; transition: opacity .18s ease, transform .18s ease; }


.hf-art {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: inherit;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.hf-art.no-src { display: none; }


.hfcard .band { position: absolute; left: 0; right: 0; top: 0; height: 5px; background: #6b7480; }
.hfcard.k-hikari .band { background: var(--gold); }
.hfcard.k-tane .band { background: #c0392b; }
.hfcard.k-tan .band { background: #d9a441; }
.hfcard.k-tanzaku .band { background: #4b7fd1; }
.hfcard.k-kasu .band { background: #6b7480; }

.hfcard .mname { font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.hfcard .glyph { position: absolute; bottom: 5px; left: 0; right: 0; text-align: center; font-size: 12px; }
.hfcard .pts { position: absolute; top: 7px; right: 5px; font-size: 9px; color: var(--dim); }

.hfcard.back {
  background: repeating-linear-gradient(45deg, #7c1f18, #7c1f18 6px, #5d1610 6px, #5d1610 12px);
  border-color: #3a0d09;
}

.hfcard.mini { width: 36px; height: 56px; }
.hfcard.mini .mname { font-size: 10px; }
.hfcard.big { width: 62px; height: 96px; }

@media (max-width: 540px), (max-height: 560px) {
  .hfcard { width: 36px; height: 56px; }
  .hfcard .mname { font-size: 10px; }
  .field { min-height: 56px; gap: 6px; }
  .seat .cards { gap: 5px; }
}

.hfcard.dim { filter: grayscale(.7) brightness(.65); }
.hfcard.selectable { outline: 2px solid var(--gold); cursor: pointer; }

.hfcard.selected { outline: 3px solid var(--koi); transform: translateY(-4px); z-index: 2; }


.hfcard.matchable {
  outline: 2px solid var(--gold);
  box-shadow: 0 0 0 1px rgba(216, 165, 60, .5),
              0 0 8px 2px rgba(216, 165, 60, .75),
              0 0 18px 5px rgba(216, 165, 60, .35),
              0 2px 6px rgba(0, 0, 0, .45);
  transform: translateY(-3px);
  z-index: 2;
}


.hfcard.matchable { animation: hf-match-glow 1.6s ease-in-out infinite alternate; }
@keyframes hf-match-glow {
  from {
    box-shadow: 0 0 0 1px rgba(216, 165, 60, .35),
                0 0 5px 1px rgba(216, 165, 60, .5),
                0 0 12px 3px rgba(216, 165, 60, .22),
                0 2px 6px rgba(0, 0, 0, .45);
  }
  to {
    box-shadow: 0 0 0 1px rgba(216, 165, 60, .6),
                0 0 10px 3px rgba(216, 165, 60, .85),
                0 0 24px 8px rgba(216, 165, 60, .4),
                0 2px 6px rgba(0, 0, 0, .45);
  }
}
@media (prefers-reduced-motion: reduce) {
  .hfcard.matchable { animation: none; }
}


.field .hfcard.matchable { outline-color: var(--gold); }

.hfcard.flipping { --flip-half: 200ms; animation: hf-flip-in var(--flip-half) linear forwards; }
@keyframes hf-flip-in { from { transform: rotateY(0); } to { transform: rotateY(90deg); } }


.hfcard.flipping.out { animation: hf-flip-out var(--flip-half, 200ms) linear forwards; }
@keyframes hf-flip-out { from { transform: rotateY(90deg); opacity: 1; } to { transform: rotateY(150deg); opacity: 0; } }


.field .hfcard.reveal {
  visibility: hidden;
  opacity: 1; 
  backface-visibility: hidden; 
  animation: hf-reveal-a var(--rv, 300ms) cubic-bezier(.3,.65,.4,1) forwards;
}
.field .hfcard.reveal.is-flipped { visibility: visible; }
.field .hfcard.reveal::before {
  content: '';
  
  visibility: visible;
  position: absolute;
  inset: -1px; 
  border-radius: inherit;
  background: repeating-linear-gradient(45deg, #7c1f18, #7c1f18 6px, #5d1610 6px, #5d1610 12px);
  border: 1px solid #3a0d09;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .45);
}
.field .hfcard.reveal.is-flipped::before {
  animation: hf-reveal-back-out calc(var(--rv, 300ms) * .5) ease forwards;
}
@keyframes hf-reveal-a {
  from { transform: rotateY(0) rotate(var(--rz, 0deg)); box-shadow: 0 2px 6px rgba(0, 0, 0, .45); }
  to   { transform: rotateY(90deg) rotate(var(--rz, 0deg)); box-shadow: 0 10px 20px rgba(0, 0, 0, .55); }
}
@keyframes hf-reveal-b {
  from { transform: rotateY(-90deg) rotate(var(--rz, 0deg)); box-shadow: 0 10px 20px rgba(0, 0, 0, .55); }
  to   { transform: rotateY(0) rotate(0deg); box-shadow: 0 2px 6px rgba(0, 0, 0, .45); }
}

@keyframes hf-reveal-back-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}
.field .hfcard.reveal.is-flipped {
  animation: hf-reveal-b var(--rv, 300ms) cubic-bezier(.3,.65,.4,1) forwards;
  transform: rotateY(0) rotate(var(--rfz, 0deg)); 
  z-index: 6;
}

.field .hfcard.reveal.fly {
  animation: hf-fly var(--rf, 240ms) cubic-bezier(.3,.65,.4,1) forwards;
  z-index: 5;
}
@keyframes hf-fly {
  from { transform: translate(var(--fx, 0px), var(--fy, 0px)); }
  to   { transform: translate(0, 0); }
}
.field .hfcard.reveal.fly::before { box-shadow: 0 8px 18px rgba(0, 0, 0, .5); }
@media (max-width: 540px), (max-height: 560px) {
  .field .hfcard.reveal.is-flipped { z-index: 6; }
}
@media (prefers-reduced-motion: reduce) {
  
  .field .hfcard.reveal,
  .field .hfcard.reveal.is-flipped { animation: none; transform: none; visibility: visible; }
  .field .hfcard.reveal::before { opacity: 0; }
  .field .hfcard.reveal.fly { animation: none; transform: none; }
}


.hfcard.dealt {
  --deal-scale: .72;
  --deal-tilt: 5deg;
  opacity: 1;
  transform: translate(var(--dx, 0px), var(--dy, 0px)) scale(var(--deal-scale)) rotate(var(--deal-tilt));
}
.hfcard.dealt.in {
  transition: transform var(--deal-fly, .3s) var(--deal-ez, cubic-bezier(.25,.62,.35,1)),
              box-shadow var(--deal-fly, .3s) ease-out;
  transform: translate(0, 0) scale(1) rotate(0deg);
  box-shadow: 0 10px 22px rgba(0, 0, 0, .5); 
  z-index: 4; 
}
@media (max-width: 540px), (max-height: 560px) {
  .hfcard.dealt { --deal-scale: .78; }
}
@media (prefers-reduced-motion: reduce) {
  
  .hfcard.dealt, .hfcard.dealt.in { transition: none; transform: none; }
}



.takefly-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}
.takefly-card {
  position: fixed;
  margin: 0;
  opacity: 1;
  transform: none;
  transform-origin: top left;
  box-shadow: 0 10px 20px rgba(0, 0, 0, .5); 
  will-change: transform;
}
.takefly-fly {
  animation: hf-take-fly var(--tf, 300ms) cubic-bezier(.3,.65,.4,1) var(--td, 0ms) both;
}
@keyframes hf-take-fly {
  from {
    transform: translate(0, 0) scale(1) rotate(var(--take-rot, 3deg));
    box-shadow: 0 12px 24px rgba(0, 0, 0, .55);
  }
  60% {
    
    transform: translate(var(--txm, var(--tx, 0px)), var(--tym, var(--ty, 0px))) scale(var(--tsm, 1))
               rotate(-2deg);
  }
  to {
    transform: translate(var(--tx, 0px), var(--ty, 0px)) scale(var(--ts, 1)) rotate(0deg);
    box-shadow: 0 2px 6px rgba(0, 0, 0, .45);
  }
}
.takencol .hfcard.takefly-wait { visibility: hidden; }
.takefly-land { animation: hf-take-land var(--take-land, 320ms) ease-out; }
@keyframes hf-take-land {
  from { box-shadow: 0 0 0 2px rgba(216, 165, 60, .9), 0 0 12px 3px rgba(216, 165, 60, .55); }
  to   { box-shadow: 0 0 0 0 rgba(216, 165, 60, 0); }
}
@media (prefers-reduced-motion: reduce) {
  
  .takefly-fly, .takefly-land { animation: none; }
}
