/* 0.9.17 rules/feel presentation --------------------------------------- */

.self-hand-count {
  display: inline-grid;
  place-items: center;
  min-width: 72px;
  min-height: 32px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.28);
  background: rgba(0,0,0,.62);
  color: #fff;
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .07em;
  box-shadow: 0 4px 10px rgba(0,0,0,.25);
  white-space: nowrap;
}

.table-slot.empty-table-slot {
  opacity: 0;
  pointer-events: none;
}

.self-face-row button.table-play-card,
.self-face-row button.table-blind-card {
  appearance: none;
  padding: 0;
}

.self-face-row button.table-play-card {
  transition: transform .14s ease, box-shadow .14s ease, filter .14s ease;
}

.self-face-row button.table-play-card:hover,
.self-face-row button.table-play-card:focus-visible,
.self-face-row button.table-play-card.selected {
  transform: translateY(-8px) !important;
  outline: none;
  box-shadow: 0 10px 20px rgba(0,0,0,.36), 0 0 0 3px var(--accent);
  z-index: 12;
}

.self-face-row .exposed-blind {
  transform: none !important;
  transition: transform .14s ease, box-shadow .14s ease, filter .14s ease;
}

.self-face-row .exposed-blind:hover,
.self-face-row .exposed-blind:focus-visible {
  transform: translateY(-7px) rotate(-1deg) !important;
  outline: none;
  box-shadow: 0 10px 20px rgba(0,0,0,.38), 0 0 0 3px var(--accent);
}

.player-out {
  opacity: .48;
  filter: saturate(.55);
}

/* Empty means visually empty: count 0 must not leave card backs on Draw. */
.pile-draw.is-empty .stacked {
  display: none !important;
}

/* Live pile: public cards should look physically played, not perfectly stacked. */
.pile-discard {
  position: relative;
  overflow: visible;
}

.pile-discard.is-empty .card,
.pile-discard.is-empty .empty-pile {
  display: none !important;
}

.pile-mess-card {
  position: absolute !important;
  left: 0;
  top: 0;
  margin: 0 !important;
  pointer-events: none;
  transform: translate(var(--pile-x, 0px), var(--pile-y, 0px)) rotate(var(--pile-r, 0deg));
  z-index: var(--pile-z, 1);
}

.pile-run-indicator {
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  transform: translateX(-50%);
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.22);
  background: rgba(0,0,0,.72);
  color: rgba(255,255,255,.92);
  font-size: .66rem;
  font-weight: 900;
  letter-spacing: .03em;
  white-space: nowrap;
  box-shadow: 0 4px 10px rgba(0,0,0,.25);
}

.pile-run-indicator.next-burn {
  border-color: var(--accent);
  color: #fff;
}

.pile-run-indicator .run-note {
  color: var(--accent);
  font-size: .61rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.pile-main-count.is-zero,
.discard-count.is-zero {
  opacity: 0;
}

/* Keep the live pile total in the reserved header band. Played cards are
   deliberately messy and can extend over every lower edge of the pile. */
.pile-main-count {
  top: -8px;
  right: -14px;
  bottom: auto !important;
  z-index: 40;
  pointer-events: none;
}

/* Host/local table option: choose turn order between deals. Connected clients
   see the same direction but cannot change the authoritative room setting. */
.direction-control {
  display: grid;
  justify-items: center;
  gap: 4px;
  color: rgba(255,255,255,.68);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.direction-toggle {
  width: 42px;
  min-height: 36px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 10px;
  background: rgba(0,0,0,.28);
  color: #fff;
  padding: 4px;
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.direction-toggle:disabled {
  cursor: default;
  opacity: .56;
}

.reveal-shithead {
  border-color: var(--accent) !important;
  font-weight: 900;
}

.shithead-reveal-panel {
  position: absolute;
  left: 50%;
  bottom: 4%;
  z-index: 220;
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: 7px;
  padding: 10px 14px;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 16px;
  background: rgba(22,13,8,.82);
  color: rgba(255,255,255,.9);
  box-shadow: 0 10px 28px rgba(0,0,0,.36);
  pointer-events: none;
}

.shithead-reveal-panel > strong {
  font-size: .72rem;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.shithead-reveal-cards {
  display: flex;
  justify-content: center;
  gap: 7px;
}

.shithead-reveal-cards .card {
  width: 54px;
  font-size: 1rem;
}

@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; }
  .controls {
    min-width: 0;
    flex: 1 1 220px;
    flex-wrap: wrap !important;
  }
  .direction-control-label { display: none; }
  .direction-control { font-size: .58rem; }
  .direction-toggle { width: 36px; min-height: 32px; font-size: 1.1rem; }
  .shithead-reveal-panel { bottom: 3%; padding: 8px 10px; }
  .shithead-reveal-cards .card { width: 44px; }
}

/* Short, functional card-motion ghosts. */
.card-flight-ghost {
  position: fixed !important;
  left: 0;
  top: 0;
  z-index: 10000 !important;
  width: 62px !important;
  min-height: 88px;
  margin: 0 !important;
  pointer-events: none !important;
  transform-origin: 50% 50%;
  box-shadow: 0 10px 24px rgba(0,0,0,.42) !important;
  will-change: transform, opacity;
}

.card-flight-ghost.card-back {
  min-height: 88px;
}

/* The actual card count and available width decide the overlap. */
.hand.hand-many button.card {
  margin-left: var(--adaptive-hand-margin, -12px) !important;
  transform: rotate(calc((var(--card-index) - var(--card-mid)) * var(--adaptive-hand-rotation, 1.7deg))) !important;
}

.hand.hand-many button.card:first-child {
  margin-left: 0 !important;
}

.hand.hand-many button.card.selected,
.hand.hand-many button.card:focus-visible {
  transform: translateY(-22px) rotate(0deg) scale(1.035) !important;
}

@media (max-width: 700px) {
  .self-hand-count {
    min-width: 64px;
    min-height: 29px;
    padding: 4px 8px;
    font-size: .68rem;
  }

  .pile-run-indicator {
    top: calc(100% + 5px);
    max-width: 118px;
    padding: 3px 6px;
    font-size: .6rem;
  }

  .pile-run-indicator .run-note { font-size: .55rem; }
  .card-flight-ghost { width: 52px !important; min-height: 74px; }
}

@media (prefers-reduced-motion: reduce) {
  .self-face-row button.table-play-card,
  .self-face-row .exposed-blind { transition: none; }
}
