.hand {
  display: flex;
  max-width: 650px;
  width: 100%;
  background: #eee;
  padding: 10px;
  box-sizing: border-box;
  margin-bottom: 10px;
  position: relative;
}

.card-container {
  overflow: visible;
  width: 1px;
  flex-grow: 1;
  position: relative;
  isolation: isolate;
}

.card-container[data-discarded="true"] .card {
  filter: grayscale(85%) brightness(0.7);
}

.discard-stamp {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-18deg);
  padding: 6px 14px;
  border: 3px solid #d62828;
  color: #d62828;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.75);
  box-shadow:
    0 2px 10px rgba(0, 0, 0, 0.25),
    0 0 14px rgba(214, 40, 40, 0.45);
  pointer-events: none;
}

.card-container.tutorial-highlight {
  animation: tutorialPulse 1.1s ease-in-out infinite;
  box-shadow:
    0 0 0 3px rgba(255, 230, 80, 0.95),
    0 0 26px rgba(255, 215, 0, 0.85),
    0 0 44px rgba(255, 215, 0, 0.55);
  border-radius: 10px;
  transform: translateY(-3px) scale(1.02);
}

.card-container.tutorial-highlight::after {
  content: "tap me";
  position: absolute;
  top: -26px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 230, 80, 0.95);
  color: #3a2a00;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.2),
    0 0 10px rgba(255, 215, 0, 0.7);
  pointer-events: none;
  animation: tapMeFloat 1.4s ease-in-out infinite;
}

@keyframes tutorialPulse {
  0% {
    box-shadow:
      0 0 0 3px rgba(255, 230, 80, 0.85),
      0 0 18px rgba(255, 215, 0, 0.6),
      0 0 34px rgba(255, 215, 0, 0.45);
  }
  50% {
    box-shadow:
      0 0 0 3px rgba(255, 230, 80, 1),
      0 0 30px rgba(255, 215, 0, 0.95),
      0 0 52px rgba(255, 215, 0, 0.7);
  }
  100% {
    box-shadow:
      0 0 0 3px rgba(255, 230, 80, 0.85),
      0 0 18px rgba(255, 215, 0, 0.6),
      0 0 34px rgba(255, 215, 0, 0.45);
  }
}

@keyframes tapMeFloat {
  0% {
    transform: translate(-50%, 0);
    opacity: 0.9;
  }
  50% {
    transform: translate(-50%, -6px);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, 0);
    opacity: 0.9;
  }
}

.card-container:last-child {
  width: 100px;
  flex-grow: 0;
}

.card {
  width: 100px;
  height: 200px;
  background: darksalmon;
  border: 5px solid #000;
  box-shadow: -5px 0px 10px #000c;
  box-sizing: border-box;
  position: relative;
}

.card-type-offense { border-color: #8b3030; }
.card-type-magic { border-color: #4a7f9e; }
.card-type-defense { border-color: #6b3a1a; }
.card-type-special { border-color: #5a5a5a; }
.card-type-resource { border-color: #b8895a; }

/* Texture overlay restricted to the border zone — inset: -5px matches border-width.
   The mask subtracts the inner card area so the texture only shows on the 5px border ring.
   mix-blend-mode: multiply tints the texture into the type border color. */
.card::before {
  content: '';
  position: absolute;
  inset: -5px;
  background: var(--card-border-texture-url) repeat;
  mix-blend-mode: overlay;
  opacity: 0.75;
  pointer-events: none;
  mask-image:
    linear-gradient(black, black),
    linear-gradient(black, black);
  mask-size:
    100% 100%,
    calc(100% - 10px) calc(100% - 10px);
  mask-position: 0 0, 5px 5px;
  mask-repeat: no-repeat;
  mask-composite: subtract;
  -webkit-mask-composite: source-out;
}

.card-container.dimmed .card {
  filter: grayscale(100%);
}

.your-turn .card-container.playable {
  animation: playablePulse 1.6s ease-in-out infinite;
}

.your-turn .card-container.playable.long-press {
  animation: none;
}

.your-turn .card-container.playable .card {
  box-shadow:
    -5px 0px 10px #000c,
    0 0 18px rgba(255, 215, 0, 0.55),
    0 0 32px rgba(255, 215, 0, 0.35);
}

@keyframes playablePulse {
  0% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
  100% {
    transform: translateY(0);
  }
}

.card-name {
  background-color: #00000088;
  border-radius: 10px;
  padding: 3px;
  display: flex;
  align-items: center; /* Centers text vertically */
  justify-content: center; /* Centers text horizontally */
  text-align: center;
}

.card-top-left {
  background-color: #00000088;
  border-radius: 10px;
  padding: 3px;
}

.card-top-right {
  background-color: #00000088;
  border-radius: 10px;
  padding: 5px;
  color: white;
}

.card-cost {
  background-color: #00000088;
  border-radius: 10px;
  padding: 3px;
}

.long-press {
  transform: translateY(-28px) scale(1.03);
}

.long-press .card {
  box-shadow:
    -5px 0px 10px #000c,
    0 0 18px rgba(46, 196, 182, 0.7),
    0 0 30px rgba(46, 196, 182, 0.45);
  border-color: rgba(46, 196, 182, 0.9);
}

.long-press::after {
  content: "selected";
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(46, 196, 182, 0.95);
  color: #083c36;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

/* ── Fan Hand Style ── */
.hand-fan {
  justify-content: center;
  padding-bottom: 30px;
  background: transparent;
}

.hand-fan .card-container {
  transition: transform 0.2s ease, z-index 0s;
}

.your-turn .hand-fan .card-container.playable {
  animation: fanPlayablePulse 1.6s ease-in-out infinite;
}

.your-turn .hand-fan .card-container.playable.long-press {
  animation: none;
}

@keyframes fanPlayablePulse {
  0%   { translate: 0 0; }
  50%  { translate: 0 -3px; }
  100% { translate: 0 0; }
}

.hand-fan .card-container:hover {
  transform: translateY(-35px) scale(1.12) rotate(0deg) !important;
  z-index: 10;
}

.hand-fan .card-container.long-press {
  transform: translateY(-40px) scale(1.12) rotate(0deg) !important;
  z-index: 10;
}

/* ── Card Flight Animation ── */
.card-flight-anim {
  border-radius: 4px;
  filter: drop-shadow(0 4px 20px rgba(0, 0, 0, 0.6));
}

.card-flight-anim .card {
  width: 100% !important;
  height: 100% !important;
  border-width: 3px;
}


/* Unplayable cards are shown in greyscale — no dark overlay */

.card-container.dimmed .card-top-right {
  z-index: 2;
}

@keyframes card-discard-pulse {
  0%, 100% {
    filter: brightness(0.7);
  }
  50% {
    filter: brightness(1.5) drop-shadow(0 0 10px rgba(255, 210, 60, 1));
  }
}

.card-container.dimmed:hover .card-top-right {
  animation: card-discard-pulse 1.5s ease-in-out infinite;
}
