/* ═══════════════════════════════════════════════════════════════
 * phom.css — Phỏm (Tá Lả) game-specific styles
 * v4.8.4: smooth rendering, card selection animation, deal/eat/discard animations
 * ═══════════════════════════════════════════════════════════════ */

/* ── Deck pile (nọc bài — center of table) ────────────────────── */
.ph-deck-pile {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 52px;
  height: 73px;
  background: url('/assets/cards/back_light.png') center/contain no-repeat;
  border-radius: 6px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  box-shadow: 2px 3px 10px rgba(0, 0, 0, 0.2);
  z-index: 5;
}

.ph-deck-count {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  min-width: 26px;
  height: 26px;
  line-height: 26px;
  text-align: center;
  border-radius: 50%;
  padding: 0 2px;
  z-index: 3;
}

.ph-deck-pile.ph-deck-clickable {
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.ph-deck-pile.ph-deck-clickable:hover {
  transform: translate(-50%, -50%) scale(1.06);
  box-shadow: 2px 3px 14px rgba(59, 126, 229, 0.4);
}

.ph-deck-pile.ph-deck-clickable:active {
  transform: translate(-50%, -50%) scale(0.97);
}

/* round indicator removed */

/* ── Per-seat discard piles (next to seat, toward center) ─────── */
.ph-seat-discards {
  position: absolute;
  display: flex;
  z-index: 8;
  pointer-events: none;
}

.ph-seat-discards img {
  width: 44px;
  height: auto;
  border-radius: 3px;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15));
}

.ph-seat-discards img:last-child {
  opacity: 1;
}

.ph-seat-discards img.ph-last-discard {
  opacity: 1;
  border: 2px solid var(--bc-warning, #f59e0b);
  border-radius: 4px;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.4);
  z-index: 2;
  position: relative;
}

.ph-seat-discards img:not(:first-child) {
  margin-left: -18px;
}

/* Between seat and center — desktop */
.ph-discards-top {
  top: 21%;
  left: 18%;
}

.ph-discards-left {
  left: 18%;
  bottom: 36%;
}

.ph-discards-right {
  right: 18%;
  top: 21%;
  flex-direction: row-reverse;
}

.ph-discards-right img:not(:first-child) {
  margin-left: 0;
  margin-right: -18px;
}

.ph-discards-bottom {
  bottom: 36%;
  right: 18%;
}

/* Mobile adjustments */
@media (max-width: 600px) {
  .ph-seat-discards img {
    width: 36px;
  }

  .ph-seat-discards img:not(:first-child) {
    margin-left: -13px;
  }

  .ph-discards-right img:not(:first-child) {
    margin-left: 0;
    margin-right: -13px;
  }

  .ph-discards-top {
    top: 21%;
    left: 18%;
  }

  .ph-discards-left {
    left: 19%;
    bottom: 40%;
  }

  .ph-discards-right {
    right: 19%;
    top: 21%;
  }

  .ph-discards-bottom {
    bottom: 40%;
    right: 18%;
  }
}

/* ── Eaten card indicators at seat ───────────────────────────── */
.ph-seat-phoms {
  display: flex;
  gap: 2px;
  margin-top: 2px;
}

.ph-phom-group {
  display: flex;
  gap: 0;
  padding: 1px 2px;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 3px;
}

.ph-phom-group img {
  width: 40px;
  height: auto;
  border-radius: 2px;
  margin-left: -6px;
}

.ph-phom-group img:first-child {
  margin-left: 0;
}

.ph-phom-group .ph-eaten-marker {
  border: 1.5px solid var(--bc-success, #22c55e);
}

/* ══════════════════════════════════════════════════════════════════
 * EAT PREVIEW — show possible phom options when canEat
 * ══════════════════════════════════════════════════════════════════ */
.ph-eat-preview {
  display: none;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  background: rgba(34, 197, 94, 0.08);
  border: 1.5px solid rgba(34, 197, 94, 0.3);
  border-radius: 10px;
  margin-bottom: 4px;
  min-height: 44px;
  flex-wrap: wrap;
  animation: fadeSlideUp 0.2s ease-out;
}

.ph-eat-preview.active {
  display: flex;
}

.ph-eat-preview-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--bc-success, #22c55e);
  white-space: nowrap;
}

.ph-eat-option {
  display: flex;
  gap: 2px;
  padding: 3px 5px;
  background: rgba(34, 197, 94, 0.12);
  border: 2px solid rgba(34, 197, 94, 0.3);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}

.ph-eat-option:hover {
  border-color: var(--bc-success, #22c55e);
  transform: translateY(-2px);
}

.ph-eat-option:active {
  transform: scale(0.96);
}

.ph-eat-option img {
  width: 32px;
  height: auto;
  border-radius: 3px;
}

.ph-eat-option .ph-eat-new {
  border: 2px solid var(--bc-success, #22c55e);
  border-radius: 4px;
}

@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ══════════════════════════════════════════════════════════════════
 * PHOM HIGHLIGHT IN HAND — colored underline for card groups
 * ══════════════════════════════════════════════════════════════════ */
.tl-card.ph-group-0::after,
.tl-card.ph-group-1::after,
.tl-card.ph-group-2::after,
.tl-card.ph-group-3::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 10%;
  right: 10%;
  height: 4px;
  border-radius: 2px;
}

.tl-card.ph-group-0::after {
  background: #22c55e;
}

.tl-card.ph-group-1::after {
  background: #3b82f6;
}

.tl-card.ph-group-2::after {
  background: #f59e0b;
}

.tl-card.ph-group-3::after {
  background: #ec4899;
}

/* cạ indicator — subtle dashed underline */
.tl-card.ph-ca::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 10%;
  right: 10%;
  height: 3px;
  border-radius: 2px;
  background: rgba(148, 163, 184, 0.5);
  border-top: 1.5px dashed rgba(148, 163, 184, 0.7);
}

/* locked card (in exposed phom, non-discardable during playing) */
.tl-card.ph-locked {
  opacity: 0.95;
  pointer-events: auto;
}

.tl-card.ph-locked::before {
  content: '\1F512';
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 10px;
  z-index: 2;
  line-height: 1;
}

/* visual gap spacer between phom/cạ/junk groups */
.ph-hand-gap {
  width: 10px;
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════════════
 * DRAG & DROP CARD REORDER
 * ══════════════════════════════════════════════════════════════════ */
.tl-card.ph-dragging {
  opacity: 0.4;
  transform: scale(0.92) !important;
}

.tl-card.ph-drag-over {
  border-left: 3px solid var(--bc-primary, #3b7ee5);
}

/* ══════════════════════════════════════════════════════════════════
 * STAGING AREA (hạ bài phase)
 * ══════════════════════════════════════════════════════════════════ */
.ph-staging-area {
  display: none;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  background: rgba(99, 102, 241, 0.08);
  border: 1px dashed rgba(99, 102, 241, 0.3);
  border-radius: 8px;
  margin-bottom: 6px;
  min-height: 42px;
  flex-wrap: wrap;
}

.ph-staging-area.active {
  display: flex;
}

.ph-staged-phom {
  display: flex;
  gap: 1px;
  padding: 3px 4px;
  background: rgba(34, 197, 94, 0.12);
  border: 1.5px solid rgba(34, 197, 94, 0.4);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s;
  position: relative;
}

.ph-staged-phom:hover {
  border-color: var(--bc-danger, #ef4444);
}

.ph-staged-phom:hover::after {
  content: '\2715';
  position: absolute;
  top: -6px;
  right: -6px;
  width: 14px;
  height: 14px;
  background: var(--bc-danger, #ef4444);
  color: #fff;
  font-size: 8px;
  line-height: 14px;
  text-align: center;
  border-radius: 50%;
}

.ph-staged-phom img {
  width: 28px;
  height: auto;
  border-radius: 3px;
}

.ph-staging-hint {
  font-size: 11px;
  color: var(--bc-muted, #94a3b8);
}

/* ── Multi-select card highlight ─────────────────────────────── */
.tl-card.tl-card-multi-selected {
  outline: 2px solid var(--bc-primary, #3b7ee5);
  border-radius: 6px;
}

/* ── Selected card lift (handled via JS transform + CSS transition) ─── */
.tl-card.selected {
  filter: brightness(1.05);
}

/* ── Action buttons ──────────────────────────────────────────── */
#btnEat {
  background: var(--bc-success, #22c55e);
  color: #fff;
}

#btnEat:not(:disabled):hover {
  background: #16a34a;
}

#btnDraw {
  background: var(--bc-primary, #3b7ee5);
  color: #fff;
}

#btnDeclareDone {
  background: var(--bc-success, #22c55e);
  color: #fff;
  font-weight: 600;
}

#btnDoneSending {
  background: var(--bc-warning, #f59e0b);
  color: #fff;
  font-size: 12px;
}

/* ── Score summary ───────────────────────────────────────────── */
.ph-score-summary {
  background: rgba(0, 0, 0, 0.8);
  border-radius: 12px;
  padding: 16px;
  color: #fff;
  max-width: 400px;
  margin: 0 auto;
}

.ph-score-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ph-score-row.winner {
  color: var(--bc-success, #22c55e);
  font-weight: 700;
}

.ph-score-row.chay {
  color: var(--bc-danger, #ef4444);
}

/* ── Send target picker ──────────────────────────────────────── */
.ph-send-picker {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(30, 30, 46, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 16px;
  z-index: 100;
  min-width: 260px;
  max-width: 360px;
}

.ph-send-picker-title {
  color: #e2e8f0;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  text-align: center;
}

.ph-send-target-btn {
  display: block;
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 8px;
  background: rgba(99, 102, 241, 0.2);
  border: 1px solid rgba(99, 102, 241, 0.4);
  border-radius: 8px;
  color: #c7d2fe;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

.ph-send-target-btn:hover {
  background: rgba(99, 102, 241, 0.4);
}

.ph-send-cancel-btn {
  display: block;
  width: 100%;
  padding: 8px;
  margin-top: 4px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #94a3b8;
  font-size: 13px;
  cursor: pointer;
}

/* ── Chốt flash ──────────────────────────────────────────────── */
@keyframes chotFlash {

  0%,
  100% {
    background: transparent;
  }

  50% {
    background: rgba(239, 68, 68, 0.15);
  }
}

.ph-chot-flash {
  animation: chotFlash 0.5s ease-in-out 3;
}

/* ── Junk score badge (after game result) ─────────────────────── */
.ph-junk-score {
  background: rgba(0, 0, 0, 0.6) !important;
  color: #fca5a5 !important;
  border: none !important;
  font-weight: 800 !important;
  font-size: 13px !important;
  padding: 3px 10px !important;
  border-radius: 12px !important;
  white-space: nowrap;
  z-index: 20;
}

.ph-junk-me {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 6px;
  white-space: nowrap;
  z-index: 20;
}

/* ── End-game: compact revealed hands ─────────────────────────── */
.tl-seat .tl-mini-card {
  width: 52px !important;
}

/* ── My exposed phoms row (above hand) ───────────────────────── */
.ph-my-exposed-phoms {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 4px;
  pointer-events: auto;
}

.ph-my-exposed-phoms:empty {
  display: none;
}

.ph-my-exposed-phoms .ph-phom-group {
  display: flex;
  gap: 0;
  padding: 2px 3px;
  background: rgba(34, 197, 94, 0.1);
  border: 1.5px solid rgba(34, 197, 94, 0.4);
  border-radius: 5px;
}

.ph-my-exposed-phoms .ph-phom-group img {
  width: 34px;
  height: auto;
  border-radius: 3px;
  margin-left: -8px;
}

.ph-my-exposed-phoms .ph-phom-group img:first-child {
  margin-left: 0;
}

/* ── Status text below deck pile ─────────────────────────────── */
.tl-status {
  z-index: 50;
  position: relative;
  margin-top: 84px;
}

/* ── Discard pile history (hidden) ───────────────────────────── */
.ph-discard-pile-history {
  display: none;
}

/* ══════════════════════════════════════════════════════════════════
 * DEAL CARD ANIMATION — cards fly from table center to players
 * ══════════════════════════════════════════════════════════════════ */
.tl-deal-card {
  position: fixed;
  width: 56px;
  aspect-ratio: 242 / 340;
  z-index: 50;
  pointer-events: none;
  transition: transform 300ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 300ms ease;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
  border-radius: 4px;
}

.tl-deal-card img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 4px;
}

/* ══════════════════════════════════════════════════════════════════
 * EAT CARD FLY — card flies from discard to player
 * ══════════════════════════════════════════════════════════════════ */
.ph-eat-fly {
  position: fixed;
  width: 52px;
  aspect-ratio: 242 / 340;
  z-index: 50;
  pointer-events: none;
  transition: transform 350ms cubic-bezier(0.2, 0.8, 0.3, 1), opacity 350ms ease;
  box-shadow: 0 4px 16px rgba(34, 197, 94, 0.5);
  border-radius: 4px;
}

.ph-eat-fly img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 4px;
}

/* ══════════════════════════════════════════════════════════════════
 * DISCARD CARD FLY — card flies from player to discard area
 * ══════════════════════════════════════════════════════════════════ */
.ph-discard-fly {
  position: fixed;
  width: 52px;
  aspect-ratio: 242 / 340;
  z-index: 50;
  pointer-events: none;
  opacity: 0.7;
  transition: transform 340ms cubic-bezier(0.2, 0.8, 0.3, 1), opacity 340ms ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  border-radius: 4px;
}

.ph-discard-fly img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 4px;
}

/* ── Phỏm: fewer cards (9-10) → less overlap on small screens ── */
@media (max-width: 430px) {
  .tl-card:not(:first-child) {
    margin-left: calc((100vw - 6px) / -13);
  }
}