/* ═══════════════════════════════════════════════════════════
   tienlen.css — Tien Len Mien Nam card game styles
   ═══════════════════════════════════════════════════════════ */

/* ── Page layout: game table (left) + sidebar (right) ──── */
.bc-table-layout {
  display: flex;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* <=900px: sidebar becomes collapsed top bar, table fills rest */
@media (max-width: 900px) {
  .bc-table-layout {
    flex-direction: column;
  }
}

/* Phone landscape: keep row, slim sidebar */
@media (orientation: landscape) and (max-width: 932px) and (pointer: coarse) {
  .bc-table-layout { flex-direction: row; }
  .bc-table-layout .bc-sidebar {
    width: 200px !important;
    height: 100dvh !important;
    border-left: 1px solid var(--gc-border, rgba(255,255,255,0.12));
    border-bottom: none;
  }
}

/* ── Table ─────────────────────────────────────────────── */
.bc-table {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 50%, #1e5a8a 0%, #0a1e3a 100%);
  transition: background .3s;
  user-select: none;
  -webkit-user-select: none;
}
body.light-mode .bc-table {
  background: radial-gradient(ellipse at 50% 50%, #e8edf4 0%, #dce3ee 100%);
}
.bc-table::before {
  content: '';
  position: absolute; inset: 0;
  background: repeating-conic-gradient(rgba(255,255,255,0.03) 0% 25%, transparent 0% 50%) 0 0 / 40px 40px;
  transform: rotate(45deg) scale(1.5);
  pointer-events: none;
}
body.light-mode .bc-table::before {
  background: repeating-conic-gradient(rgba(59,126,229,0.04) 0% 25%, transparent 0% 50%) 0 0 / 40px 40px;
}

/* ── Seats ─────────────────────────────────────────────── */
.tl-seat {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  z-index: 10;
  transition: box-shadow 0.3s, opacity 0.3s;
}
.tl-seat-bottom { left: 50%; bottom: 25%; transform: translateX(-50%); z-index: 25; }
.tl-seat-top    { left: 50%; top: 4%;    transform: translateX(-50%); }
.tl-seat-left   { left: 4%;  top: 40%;   transform: translateY(-50%); align-items: flex-start; }
.tl-seat-right  { right: 4%; top: 40%;   transform: translateY(-50%); align-items: flex-end; }
.tl-seat-left .tl-mini-cards,
.tl-seat-right .tl-mini-cards {
  flex-direction: column;
  align-items: center;
}
.tl-seat-left .tl-mini-card:not(:first-child),
.tl-seat-right .tl-mini-card:not(:first-child) { margin-left: 0; margin-top: -46px; }

.tl-seat.tl-active-turn {
  border-radius: 12px;
}

.tl-seat-avatar {
  width: 68px; height: 68px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.15);
  background: rgba(0,0,0,0.3);
  flex-shrink: 0;
  position: relative;
  overflow: visible;
}
.tl-seat-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
/* Timer ring on avatar */
.tl-timer-ring {
  position: absolute;
  inset: -5px;
  width: calc(100% + 10px);
  height: calc(100% + 10px);
  z-index: 2;
  pointer-events: none;
  transform: rotate(-90deg);
  display: none;
}
.tl-timer-ring circle {
  fill: none;
  stroke: var(--gc-green, #2ecc71);
  stroke-width: 3.5;
  stroke-dasharray: 163.36;
  stroke-dashoffset: 0;
  stroke-linecap: round;
  transition: stroke 0.3s;
}
.tl-timer-ring.tl-timer-active { display: block; }
.tl-timer-ring.tl-timer-warn circle { stroke: var(--gc-gold, #f39c12); }
.tl-timer-ring.tl-timer-urgent circle { stroke: var(--gc-red, #ef4444); }
.tl-timer-ring.tl-timer-urgent { animation: pulse 0.5s infinite; }

.tl-card-count {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 13px;
  font-family: 'IBM Plex Mono', monospace;
  color: #fff;
  font-weight: 800;
  background: rgba(0,0,0,0.55);
  min-width: 24px;
  height: 24px;
  line-height: 24px;
  text-align: center;
  border-radius: 50%;
  padding: 0 2px;
  z-index: 3;
  pointer-events: none;
}

.tl-seat-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}
.tl-seat-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--gc-text-bright, #e8f0fa);
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tl-seat-points {
  font-size: 10px;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--gc-gold, #FFD700);
  font-weight: 500;
}

.tl-seat-title {
  font-size: 9px;
  color: var(--gc-muted, #6b8fb5);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.tl-seat-badge {
  display: none;
}

/* Opponent card fan */
.tl-seat-cards {
  display: flex;
  justify-content: center;
}
.tl-mini-cards {
  display: flex;
  justify-content: center;
  position: relative;
}
.tl-mini-card {
  width: 62px;
  aspect-ratio: 242/340;
  border-radius: 2px;
  flex-shrink: 0;
}
/* Fan direction per seat — cards curve away from table center */
.tl-seat-bottom .tl-mini-card { transform-origin: bottom center; }
.tl-seat-top .tl-mini-card    { transform-origin: top center; }
.tl-seat-left .tl-mini-card   { transform-origin: center right; }
.tl-seat-right .tl-mini-card  { transform-origin: center left; }
.tl-mini-card:not(:first-child) { margin-left: -20px; }

/* Seat states */
.tl-seat.tl-passed .tl-seat-avatar { opacity: 0.4; }
.tl-seat.tl-forfeited { opacity: 0.3; pointer-events: none; }
.tl-seat.tl-forfeited::after {
  content: 'X';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 28px;
  font-weight: 900;
  color: var(--gc-red, #ef4444);
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* Pass indicator — large overlay on player seat */
.tl-pass-label {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  background: rgba(239, 68, 68, 0.88);
  padding: 4px 10px;
  border-radius: 8px;
  white-space: nowrap;
  z-index: 15;
  animation: fadeInUp 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 8px rgba(239,68,68,0.4);
}

/* ── Table Center ──────────────────────────────────────── */
.tl-table-center {
  position: absolute;
  left: 50%; top: 42%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
/* Stacked plays container — previous plays above current */
.tl-played-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.tl-played-cards-prev {
  display: flex;
  gap: 2px;
  justify-content: center;
  align-items: center;
  opacity: 0.35;
  transform: scale(0.6);
  filter: brightness(0.7);
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  min-height: 0;
}
.tl-played-cards-prev:empty {
  display: none;
}
.tl-played-cards {
  display: flex;
  gap: 2px;
  justify-content: center;
  min-height: 80px;
  align-items: center;
}
.tl-table-card {
  width: 68px;
  aspect-ratio: 242/340;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.tl-table-card-md { width: 76px; }
.tl-table-card-lg { width: 88px; }
.tl-played-cards:has(.tl-table-card-lg) { gap: 4px; }
.tl-played-cards:has(.tl-table-card-md) { gap: 3px; }
.tl-card-fly {
  animation: cardFly 0.35s cubic-bezier(0.2, 0.8, 0.3, 1) backwards;
}
@keyframes cardFly {
  from {
    opacity: 0;
    transform: translate(var(--fly-from-x, 0), var(--fly-from-y, 0)) scale(0.4);
  }
  60% {
    opacity: 1;
  }
  to {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
}

.tl-status {
  font-size: 13px;
  color: var(--gc-muted, #6b8fb5);
  font-weight: 500;
}

/* ── Start Button (table center) ──────────────────────── */
.tl-start-btn {
  margin-top: 10px;
  font-size: 15px;
  padding: 10px 28px;
  border-radius: 10px;
  font-weight: 700;
  font-family: 'Be Vietnam Pro', sans-serif;
  cursor: pointer;
  border: none;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #0a1e3a;
  box-shadow: 0 4px 16px rgba(245,158,11,0.3);
  transition: transform 0.15s, box-shadow 0.15s;
  animation: fadeInUp 0.3s ease;
}
.tl-start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(245,158,11,0.4);
}
.tl-start-btn:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
  pointer-events: none;
}

.tl-combo-label {
  font-family: 'Bungee', cursive;
  font-size: 15px;
  color: var(--gc-gold, #FFD700);
  animation: fadeInUp 0.3s ease;
}
.tl-combo-label.chop {
  color: var(--gc-red, #ef4444);
  font-size: 18px;
  text-shadow: 0 0 8px rgba(239,68,68,0.5);
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.92); opacity: 0.7; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── My Hand ───────────────────────────────────────────── */
.tl-hand-area {
  position: absolute;
  bottom: 1%; left: 0; right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 8px calc(8px + env(safe-area-inset-bottom, 0px));
  z-index: 20;
  pointer-events: none;
}
.tl-hand-area > * {
  pointer-events: auto;
}
.tl-hand {
  display: flex;
  justify-content: center;
  padding: 24px 0 4px;
  max-width: 100%;
  overflow: visible;
  -webkit-overflow-scrolling: touch;
}
.tl-card {
  width: 74px;
  aspect-ratio: 242/340;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
  border-radius: 4px;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  transform-origin: bottom center;
}
.tl-card img {
  width: 100%; height: 100%;
  border-radius: 4px;
  pointer-events: none;
}
.tl-card:not(:first-child) { margin-left: -35px; }
/* hover/selected transforms handled via JS to preserve rotation */

/* ── Card States ──────────────────────────────────────── */
/* active: can be selected, raised slightly via transform (no opacity change) */
.tl-card.tl-active {
  cursor: pointer;
}
/* selected: currently picked */
.tl-card.tl-selected,
.tl-card.selected {
  opacity: 1;
  filter: none;
}
/* suggested: part of the hint combo */
.tl-card.tl-suggested {
  opacity: 1;
  box-shadow: 0 0 8px 2px rgba(59, 130, 246, 0.6);
  border-radius: 6px;
}

/* Badge for rank 2 (heo) */
.tl-card.tl-card-two::after {
  content: "2";
  position: absolute;
  top: -4px;
  right: -2px;
  background: #ef4444;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
  z-index: 2;
}

/* 3♠ glow on first round */
.tl-card.tl-glow-3s {
  animation: glow3s 1.2s ease-in-out infinite alternate;
}
@keyframes glow3s {
  from { box-shadow: 0 0 4px 1px rgba(34, 197, 94, 0.4); }
  to   { box-shadow: 0 0 12px 4px rgba(34, 197, 94, 0.7); border-radius: 6px; }
}

/* dimmed (legacy) */
.tl-card.dimmed {
  opacity: 0.5;
  pointer-events: none;
}

.tl-selection-hint {
  font-size: 11px;
  color: var(--gc-red, #ef4444);
  min-height: 16px;
  margin-top: 2px;
}

/* ── Action Bar ────────────────────────────────────────── */
.tl-actions {
  display: none;
  gap: 12px;
  align-items: center;
  justify-content: center;
  margin-top: 6px;
}
.tl-actions.tl-actions-visible {
  display: flex;
  animation: fadeInUp 0.2s ease;
}
.tl-actions .bc-btn {
  font-size: 15px;
  padding: 12px 28px;
  border-radius: 12px;
  font-weight: 700;
  font-family: 'Be Vietnam Pro', sans-serif;
  cursor: pointer;
  border: none;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  min-width: 110px;
  text-align: center;
  letter-spacing: 0.5px;
}
.tl-actions .bc-btn:disabled {
  opacity: 0.35;
  cursor: default;
  transform: none;
}
/* ĐÁNH BÀI — primary, bold orange */
.tl-actions .bc-btn-primary {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #0a1e3a;
  box-shadow: 0 3px 12px rgba(245,158,11,0.35);
}
.tl-actions .bc-btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(245,158,11,0.45);
}
/* BỎ LƯỢT — subtle, muted */
.tl-actions .bc-btn-secondary {
  background: rgba(200,221,240,0.08);
  border: 1px solid rgba(200,221,240,0.18);
  color: var(--gc-text, #c8ddf0);
}
.tl-actions .bc-btn-secondary:hover:not(:disabled) {
  background: rgba(200,221,240,0.15);
}
body.light-mode .tl-actions .bc-btn-secondary {
  background: rgba(0,0,0,0.04);
  border: 1px solid rgba(0,0,0,0.12);
  color: #4b5563;
}
body.light-mode .tl-actions .bc-btn-secondary:hover:not(:disabled) {
  background: rgba(0,0,0,0.08);
}

/* ── Inline Result ─────────────────────────────────────── */
.tl-inline-result {
  text-align: center;
  animation: fadeInUp 0.3s ease;
}
.tl-inline-winner {
  font-size: 18px;
  font-weight: 700;
  color: var(--gc-gold, #FFD700);
  text-shadow: 0 0 12px rgba(255,215,0,0.4);
}
.tl-inline-reason {
  font-size: 12px;
  color: var(--gc-muted, #8899aa);
  margin-top: 2px;
}
.tl-inline-rake {
  font-size: 11px;
  color: var(--gc-muted, #6b8fb5);
  margin-top: 4px;
}

/* Seat delta float */
.tl-seat-delta .tl-delta-amount {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  font-weight: 700;
}
.tl-seat-delta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
  animation: floatUp 0.5s ease;
  white-space: nowrap;
}
.tl-seat-delta.positive { color: var(--gc-green, #4ade80); }
.tl-seat-delta.negative { color: var(--gc-red, #ef4444); }

@keyframes floatUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Deal Card Animation ──────────────────────────────── */
.tl-deal-card {
  position: fixed;
  width: 56px;
  aspect-ratio: 242 / 340;
  z-index: 50;
  pointer-events: none;
  transition: transform 320ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 320ms 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;
}

/* ── Special Play Effects ──────────────────────────────── */
.tl-special-effect {
  position: absolute;
  top: 40%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Bungee', 'Be Vietnam Pro', cursive;
  font-size: 36px;
  font-weight: 800;
  z-index: 100;
  pointer-events: none;
  white-space: nowrap;
  animation: specialBoom 1.2s ease forwards;
}
.tl-effect-heo {
  color: var(--gc-gold, #FFD700);
  text-shadow: 0 0 20px rgba(255,215,0,0.6), 0 4px 12px rgba(0,0,0,0.5);
}
.tl-effect-chop {
  color: var(--gc-red, #ef4444);
  font-size: 42px;
  text-shadow: 0 0 24px rgba(239,68,68,0.7), 0 4px 12px rgba(0,0,0,0.5);
}
@keyframes specialBoom {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
  20%  { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
  40%  { transform: translate(-50%, -50%) scale(1.0); }
  80%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.1) translateY(-15px); }
}

/* ── Seat Delta Penalty Labels ────────────────────────── */
.tl-delta-penalty {
  font-size: 11px;
  font-weight: 700;
  color: var(--gc-red, #ef4444);
  text-shadow: 0 0 6px rgba(239,68,68,0.4);
  animation: floatUp 0.5s ease;
}

/* ── Sort Icon ────────────────────────────────────────── */
.tl-sort-icon {
  position: absolute;
  top: 2px;
  right: 8px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  z-index: 25;
  pointer-events: auto;
  background: none;
  border: none;
  padding: 4px;
  opacity: 0.6;
  transition: opacity 0.15s, transform 0.1s;
  display: none;
}
.tl-hand-area.tl-game-active .tl-sort-icon {
  display: block;
}
.tl-sort-icon:active {
  transform: scale(0.85);
}
.tl-sort-icon.active {
  opacity: 1;
}

/* ── Tablet (iPad) ─────────────────────────────────────── */
@media (max-width: 1024px) {
  .tl-mini-card { width: 56px; }
  .tl-mini-card:not(:first-child) { margin-left: -15px; }
  .tl-seat-left .tl-mini-card:not(:first-child),
  .tl-seat-right .tl-mini-card:not(:first-child) { margin-left: 0; margin-top: -34px; }
}

/* ── Mobile Responsive ─────────────────────────────────── */
@media (max-width: 900px) {
  .tl-seat-top    { transform: scale(0.9) translateX(-50%); }
  .tl-seat-left   { transform: scale(0.9) translateY(-50%); }
  .tl-seat-right  { transform: scale(0.9) translateY(-50%); }
  .tl-card { width: 62px; }
  .tl-card:not(:first-child) { margin-left: -30px; }
  .tl-table-card { width: 58px; }
  .tl-seat-avatar { width: 58px; height: 58px; }
  .tl-actions .bc-btn { font-size: 14px; padding: 9px 20px; }
  .bc-table { padding-bottom: env(safe-area-inset-bottom, 0px); }
}

@media (max-width: 600px) {
  .tl-card { width: 52px; }
  .tl-card:not(:first-child) { margin-left: -24px; }
  .tl-table-card { width: 54px; }
  .tl-seat-avatar { width: 52px; height: 52px; }
  .tl-seat-name { font-size: 11px; max-width: 70px; }
  .tl-actions { gap: 8px; }
  .tl-actions .bc-btn { font-size: 13px; padding: 9px 18px; min-width: 88px; }
  .tl-combo-label { font-size: 13px; }
  .tl-mini-card { width: 50px; }
  .tl-mini-card:not(:first-child) { margin-left: -12px; }
  .tl-seat-left .tl-mini-card:not(:first-child),
  .tl-seat-right .tl-mini-card:not(:first-child) { margin-left: 0; margin-top: -40px; }
  .tl-pass-label { font-size: 11px; padding: 3px 8px; }
  .tl-card-count { font-size: 12px; }
  .tl-played-cards-prev { transform: scale(0.75); }
}

/* ── Small phones (13 cards fill full width) ─────────── */
@media (max-width: 430px) {
  .tl-hand-area { padding: 0 3px calc(6px + env(safe-area-inset-bottom, 0px)); }
  .tl-card {
    width: calc((100vw - 6px) / 6);
  }
  .tl-card:not(:first-child) {
    margin-left: calc((100vw - 6px) / -9);
  }
  .tl-actions .bc-btn { font-size: 13px; padding: 8px 16px; min-width: 80px; }
  .tl-table-card { width: 50px; }
}

