.hand-dock {
  grid-column: 1 / 4;
  grid-row: 2;
  min-height: 0;
  height: 100%;
  padding: 10px 72px;
  position: relative;
  z-index: 20;
  border-color: rgba(80, 200, 255, 0.5);
  background: linear-gradient(180deg, rgba(5, 16, 28, 0.94), rgba(3, 8, 14, 0.96));
}

.hand-scroll {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: clamp(116px, 8vw, 136px);
  gap: 12px;
  overflow-x: auto;
  overflow-y: visible;
  overscroll-behavior-x: contain;
  padding: 14px 2px 10px;
  scrollbar-color: rgba(80, 200, 255, 0.7) rgba(255, 255, 255, 0.08);
}

.hand-card-wrap {
  position: relative;
  height: clamp(146px, calc(23vh - 28px), 184px);
  min-width: 0;
  overflow: visible;
}

.hand-card-wrap .card {
  width: 100%;
  height: 100%;
}

/* Move the frame, status badge and info button together when selecting a card. */
.online-game .hand-card-wrap {
  transition: transform 140ms ease;
}

.online-game .hand-card-wrap:has(.card.is-selected),
.online-game .hand-card-wrap:has(.card.is-mulligan-selected) {
  transform: translateY(-10px);
  z-index: 6;
}

.online-game .hand-card-wrap .card.is-selected,
.online-game .hand-card-wrap .card.is-mulligan-selected {
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .online-game .hand-card-wrap { transition: none; }
}

.hand-arrow {
  position: absolute;
  top: 50%;
  width: 54px;
  height: 88px;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--blue-soft);
  font-size: 3rem;
  text-shadow: var(--shadow-blue);
}

.hand-arrow.left {
  left: 8px;
}

.hand-arrow.right {
  right: 8px;
}

.card {
  position: relative;
  height: clamp(146px, calc(23vh - 28px), 184px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #f7fbff;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 6px;
  padding: 10px 9px 9px;
  text-align: left;
  cursor: pointer;
  background: linear-gradient(180deg, rgba(24, 42, 60, 0.96), rgba(5, 9, 16, 0.96));
  clip-path: polygon(10px 0, calc(100% - 10px) 0, 100% 12px, 100% calc(100% - 10px), calc(100% - 10px) 100%, 10px 100%, 0 calc(100% - 10px), 0 12px);
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease, opacity 140ms ease;
}

.card:hover,
.card.is-selected {
  transform: translateY(-5px);
  border-color: #ffffff;
  box-shadow: 0 0 22px rgba(110, 210, 255, 0.7);
}

.card.is-selected {
  outline: 2px solid var(--purple);
  outline-offset: 2px;
}

.card.is-confirmable {
  border-color: rgba(239, 184, 77, 0.92);
  box-shadow: 0 0 28px rgba(239, 184, 77, 0.58);
  animation: cardConfirmPulse 1.4s ease-in-out infinite;
}

.card-confirm-badge {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 8;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(239, 184, 77, 0.9);
  background: rgba(70, 45, 8, 0.86);
  color: #ffe28a;
  border-radius: 3px;
  padding: 5px 10px;
  font-size: 0.74rem;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  text-shadow: 0 0 10px rgba(255, 226, 138, 0.7);
  box-shadow: 0 0 16px rgba(255, 226, 138, 0.38), inset 0 0 12px rgba(255, 226, 138, 0.1);
  pointer-events: none;
  white-space: nowrap;
}

.card-reactor-badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 4;
  min-width: 30px;
  height: 18px;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 0 8px rgba(80, 200, 255, 0.22));
}

.card-reactor-badge.is-locked {
  filter: drop-shadow(0 0 8px rgba(255, 75, 67, 0.26));
}

.card-reactor-battery {
  position: relative;
  width: 28px;
  height: 17px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(117, 221, 255, 0.78);
  border-radius: 3px;
  background: linear-gradient(180deg, rgba(19, 89, 130, 0.94), rgba(4, 21, 34, 0.96));
  color: #e8fbff;
  box-shadow: inset 0 0 8px rgba(117, 221, 255, 0.18);
}

.card-reactor-battery::after {
  content: "";
  position: absolute;
  right: -4px;
  top: 4px;
  width: 3px;
  height: 7px;
  border-radius: 0 2px 2px 0;
  background: rgba(117, 221, 255, 0.82);
}

.card-reactor-battery span {
  font-size: 0.62rem;
  line-height: 1;
  font-weight: 900;
  color: #e8fbff;
  text-shadow: 0 0 8px rgba(117, 221, 255, 0.8);
}

.card-reactor-badge.is-locked .card-reactor-battery {
  border-color: rgba(255, 116, 103, 0.82);
  background: linear-gradient(180deg, rgba(84, 28, 25, 0.94), rgba(16, 9, 14, 0.96));
  box-shadow: inset 0 0 8px rgba(255, 116, 103, 0.18);
}

.card-reactor-badge.is-locked .card-reactor-battery::after {
  background: rgba(255, 116, 103, 0.82);
}

.card.is-unplayable {
  opacity: 0.62;
  cursor: not-allowed;
}

.card.defense {
  border-color: rgba(239, 184, 77, 0.65);
  background: linear-gradient(180deg, rgba(105, 70, 18, 0.95), rgba(29, 18, 8, 0.96));
}

.card.shield-card {
  border-color: rgba(80, 200, 255, 0.7);
  background: linear-gradient(180deg, rgba(22, 104, 155, 0.9), rgba(4, 22, 36, 0.96));
}

.card.military-card,
.card.control,
.card.laser {
  border-color: rgba(196, 92, 255, 0.72);
  background: linear-gradient(180deg, rgba(83, 27, 120, 0.92), rgba(18, 7, 28, 0.96));
}

.card.attack {
  border-color: rgba(255, 75, 67, 0.72);
  background: linear-gradient(180deg, rgba(118, 30, 22, 0.92), rgba(28, 8, 8, 0.96));
}

.card.utility,
.card.reaction {
  border-color: rgba(104, 221, 100, 0.66);
  background: linear-gradient(180deg, rgba(43, 118, 40, 0.86), rgba(8, 30, 14, 0.96));
}

.card.reactor-stabilize-card {
  border-color: rgba(92, 255, 226, 0.72);
  background:
    linear-gradient(180deg, rgba(18, 116, 128, 0.72), rgba(4, 22, 34, 0.92)),
    repeating-linear-gradient(135deg, rgba(92, 255, 226, 0.12) 0 6px, transparent 6px 13px);
  box-shadow: inset 0 0 18px rgba(92, 255, 226, 0.16);
}

.reactor-stabilize-wrap {
  margin-left: 8px;
}

.card.reactor-stabilize-card::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 12px;
  bottom: 12px;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(92, 255, 226, 0.82), transparent);
  box-shadow: 0 0 14px rgba(92, 255, 226, 0.52);
}

.card.reactor-stabilize-card:hover {
  border-color: rgba(210, 255, 250, 0.96);
  box-shadow: 0 0 24px rgba(92, 255, 226, 0.54), inset 0 0 22px rgba(92, 255, 226, 0.18);
}

.card.reactor-stabilize-card .reactor-stabilize-art {
  display: grid;
  place-items: center;
  align-self: stretch;
  min-height: 0;
}

.card.reactor-stabilize-card .card-name {
  font-weight: 900;
  color: #d8fffb;
  text-shadow: 0 0 10px rgba(92, 255, 226, 0.5);
}

.reactor-stabilize-core {
  width: clamp(42px, 48%, 62px);
  aspect-ratio: 1;
  border: 2px solid rgba(178, 255, 247, 0.86);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(236, 255, 255, 0.98) 0 12%, rgba(92, 255, 226, 0.9) 13% 34%, rgba(92, 255, 226, 0.18) 35% 62%, transparent 63%),
    conic-gradient(from 0deg, rgba(92, 255, 226, 0.12), rgba(255, 226, 138, 0.88), rgba(92, 255, 226, 0.2), rgba(92, 255, 226, 0.92));
  box-shadow: 0 0 18px rgba(92, 255, 226, 0.72);
  animation: reactorCorePulse 1.8s ease-in-out infinite;
}

@media (max-width: 900px), (max-height: 520px) {
  .card.reactor-stabilize-card .reactor-stabilize-core {
    width: 38px;
  }
}

.card.rarity-common {
  border-color: rgba(116, 210, 255, 0.72);
  background:
    linear-gradient(180deg, rgba(20, 86, 126, 0.88), rgba(4, 17, 29, 0.96));
}

.card.rarity-rare {
  border-color: rgba(104, 221, 100, 0.78);
  background:
    linear-gradient(180deg, rgba(34, 112, 44, 0.9), rgba(7, 31, 15, 0.96));
}

.card.rarity-epic {
  border-color: rgba(196, 92, 255, 0.82);
  background:
    linear-gradient(180deg, rgba(83, 27, 120, 0.92), rgba(18, 7, 28, 0.96));
}

.card.rarity-legendary {
  border-color: rgba(255, 194, 71, 0.9);
  background:
    linear-gradient(180deg, rgba(119, 72, 12, 0.94), rgba(29, 14, 2, 0.97));
  box-shadow:
    0 0 18px rgba(255, 166, 46, 0.26),
    inset 0 0 18px rgba(255, 218, 108, 0.1);
}

.card.has-emergency-protocol {
  border-color: rgba(255, 176, 54, 0.94);
  box-shadow:
    0 0 18px rgba(255, 160, 32, 0.46),
    inset 0 0 18px rgba(255, 176, 54, 0.12);
}

.card.has-emergency-protocol:hover,
.card.has-emergency-protocol.is-selected {
  border-color: rgba(255, 221, 132, 0.98);
  box-shadow:
    0 0 26px rgba(255, 176, 54, 0.72),
    inset 0 0 20px rgba(255, 176, 54, 0.16);
}

.card.has-repair-reaction {
  border-color: rgba(118, 238, 132, 0.9);
  box-shadow:
    0 0 18px rgba(104, 221, 100, 0.42),
    inset 0 0 18px rgba(104, 221, 100, 0.12);
}

.card.has-repair-reaction:hover,
.card.has-repair-reaction.is-selected {
  border-color: rgba(180, 255, 185, 0.98);
  box-shadow:
    0 0 26px rgba(104, 221, 100, 0.62),
    inset 0 0 20px rgba(104, 221, 100, 0.16);
}

.card-status-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  right: auto;
  z-index: 7;
  box-sizing: border-box;
  min-width: 48px;
  height: 23px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 5px;
  appearance: none;
  cursor: help;
  font-family: inherit;
  font-size: 0.68rem;
  line-height: 1;
  font-weight: 900;
  text-transform: uppercase;
  pointer-events: auto;
  transform: translateX(-50%);
  white-space: nowrap;
}

.card-protocol-badge {
  border: 1px solid rgba(255, 203, 94, 0.92);
  background: linear-gradient(180deg, rgba(96, 55, 5, 0.98), rgba(42, 22, 4, 0.98));
  color: #ffe18a;
  text-shadow: 0 0 10px rgba(255, 226, 138, 0.78);
  box-shadow: 0 0 14px rgba(255, 176, 54, 0.48), inset 0 0 10px rgba(255, 226, 138, 0.12);
}

.card-repair-badge {
  border: 1px solid rgba(165, 255, 160, 0.9);
  background: linear-gradient(180deg, rgba(27, 91, 36, 0.98), rgba(5, 38, 15, 0.98));
  color: #dbffd6;
  text-shadow: 0 0 10px rgba(184, 255, 178, 0.74);
  box-shadow: 0 0 14px rgba(104, 221, 100, 0.44), inset 0 0 10px rgba(184, 255, 178, 0.12);
}

.card-status-icon {
  font-size: 0.72em;
  line-height: 1;
  transform: translateY(-0.02em);
}

.card-repair-icon {
  font-size: 0.78em;
}

.card-info {
  appearance: none;
  position: absolute;
  right: 8px;
  top: 8px;
  z-index: 4;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.74);
  background: rgba(0, 0, 0, 0.42);
  color: #ffffff;
  border-radius: 50%;
  padding: 0;
  font-size: 0.86rem;
  font-family: inherit;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  cursor: help;
  pointer-events: auto;
  text-shadow: 0 0 10px currentColor;
}

.card-info:hover {
  color: #ffe28a;
  border-color: rgba(239, 184, 77, 0.95);
  background: rgba(70, 45, 8, 0.9);
  box-shadow: 0 0 18px rgba(239, 184, 77, 0.54);
}

.floating-card-tooltip {
  position: fixed;
  z-index: 1000;
  width: 260px;
  max-width: min(260px, calc(100vw - 28px));
  padding: 10px 12px;
  border: 1px solid rgba(239, 184, 77, 0.82);
  background: rgba(2, 8, 14, 0.97);
  color: #fff4c9;
  border-radius: 4px;
  font-size: 0.78rem;
  line-height: 1.25;
  font-weight: 800;
  text-align: left;
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.72), 0 0 18px rgba(239, 184, 77, 0.26);
  transform: translate(14px, calc(-100% - 12px));
  pointer-events: none;
  animation: tooltipIn 120ms ease-out both;
}

.floating-card-tooltip::after {
  content: "";
  position: absolute;
  left: 14px;
  bottom: -7px;
  width: 12px;
  height: 12px;
  border-right: 1px solid rgba(239, 184, 77, 0.82);
  border-bottom: 1px solid rgba(239, 184, 77, 0.82);
  background: rgba(2, 8, 14, 0.97);
  transform: rotate(45deg);
}

.card-name {
  padding: 4px 30px 0 0;
  min-height: clamp(28px, 5vh, 38px);
  display: flex;
  align-items: center;
  font-size: clamp(0.9rem, 1.85vh, 1rem);
  line-height: 1.05;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.card-art {
  min-height: clamp(46px, 8vh, 72px);
  display: grid;
  place-items: center;
  font-size: clamp(2rem, 5.5vh, 3rem);
  text-shadow: 0 0 18px currentColor;
}

.empty-hand {
  height: 184px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed rgba(80, 200, 255, 0.28);
}

