/* ═══════════════════════════════════════════════════════════
   bacay.css — Ba Cây-specific styles
   Requires: game_cards.css (shared theme, sidebar, chat, modals, buttons)
   ═══════════════════════════════════════════════════════════ */

/* ── Main layout ────────────────────────────────────────── */
.bc-game {
  width: 100vw;
  height: 100vh;
  display: flex;
  overflow: hidden;
}

/* ── Game table area ────────────────────────────────────── */
.bc-table {
  flex: 1;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 40%, var(--gc-bg-mid) 0%, var(--gc-bg-dark) 70%);
  transition: background .3s;
}
body.light-mode .bc-table {
  background: radial-gradient(ellipse at 50% 40%, #e8edf4 0%, #dce3ee 100%);
}

/* Diamond pattern overlay */
.bc-table-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 1;
  background-image:
    linear-gradient(45deg, rgba(100, 170, 230, 0.08) 1px, transparent 1px),
    linear-gradient(-45deg, rgba(100, 170, 230, 0.08) 1px, transparent 1px);
  background-size: 40px 40px;
}

/* Subtle noise texture */
.bc-table::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 256px 256px;
}

/* ── Deck (center) ──────────────────────────────────────── */
.table-deck {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 92px;
  height: 128px;
  transform: translate(-50%, -50%);
  border-radius: 14px;
  background: center / cover no-repeat url("/assets/cards/back_light.png");
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.5);
  z-index: 2;
}

.table-deck::before,
.table-deck::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 14px;
  background: center / cover no-repeat url("/assets/cards/back_light.png");
  opacity: 1;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
  z-index: -1;
}

.table-deck::before {
  transform: translate(-5px, -4px) rotate(-6deg);
}

.table-deck::after {
  transform: translate(5px, 3px) rotate(5deg);
}

/* ── Center text ────────────────────────────────────────── */
.table-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, calc(-50% - 120px));
  text-align: center;
  width: min(80%, 320px);
  pointer-events: none;
  z-index: 2;
}

.table-center strong {
  display: block;
  font-family: var(--font-head);
  font-size: 18px;
  line-height: 1.5;
  color: var(--gc-text-bright);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.table-center span {
  display: block;
  margin-top: 6px;
  color: var(--gc-muted);
  font-size: 13px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.table-center-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 14px;
  pointer-events: auto;
}

.bc-btn-center-action {
  padding: 0 20px;
  min-height: 40px;
  border-radius: 8px;
  border: none;
  background: var(--gc-blue);
  color: #fff;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.bc-btn-center-action:hover {
  background: #2563eb;
  transform: scale(1.04);
}

/* ── Seats ──────────────────────────────────────────────── */
.seat {
  position: absolute;
  width: 220px;
  transform: translate(-50%, -50%);
  z-index: 3;
}

.seat-card {
  border-radius: 12px;
  background: var(--gc-surface);
  border: 1px solid var(--gc-border);
  padding: 12px 10px;
  backdrop-filter: blur(8px);
  box-shadow: var(--gc-shadow-sm);
}

.seat-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  cursor: pointer;
  touch-action: manipulation;
  overflow: hidden;
}

.seat-head > div:not(.bc-avatar) {
  min-width: 0;
  overflow: hidden;
}

.bc-avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  overflow: visible;
  background: transparent;
  flex-shrink: 0;
  position: relative;
}

.bc-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.seat-name {
  font-weight: 700;
  font-size: 13px;
  color: var(--gc-text-bright);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
}

.seat-owner-badge {
  color: var(--gc-gold);
  font-size: 14px;
  margin-right: 2px;
}

.seat-title {
  font-size: 10px;
  color: var(--gc-muted, #6b8fb5);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
}

.seat-points {
  font-size: 12px;
  color: var(--gc-gold-soft);
  font-family: var(--font-mono);
}

.seat-status {
  margin-top: 2px;
  font-size: 11px;
  color: var(--gc-muted);
}

.hand {
  margin-top: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  min-height: 104px;
}

.mini-card,
.empty-card,
.deal-card {
  width: 56px;
  aspect-ratio: 242 / 340;
  border-radius: 5px;
  flex-shrink: 0;
}

.mini-card {
  position: relative;
  border: none;
  background: transparent;
  padding: 0;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.mini-card img,
.deal-card img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.mini-card.peekable {
  cursor: pointer;
}

.empty-card {
  border: 1px dashed rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 5px;
}

.seat-delta {
  margin-top: 8px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 12px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.seat-delta.pos { color: var(--gc-green); }
.seat-delta.neg { color: var(--gc-red); }

/* ── Peek overlay ───────────────────────────────────────── */
.peek-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 8;
}

.peek-overlay.active {
  pointer-events: auto;
}

.peek-panel {
  width: min(760px, calc(100% - 32px));
  padding: 16px 16px 18px;
  border-radius: 14px;
  background: rgba(13, 32, 53, 0.95);
  border: 1px solid var(--gc-border-accent);
  backdrop-filter: blur(12px);
  box-shadow: 0 22px 40px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(-8px) scale(0.96);
  transition: opacity 180ms ease, transform 220ms ease;
  pointer-events: auto;
}

.peek-overlay.active .peek-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.peek-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.peek-header strong {
  font-size: 15px;
  font-family: var(--font-head);
  line-height: 1.4;
  color: var(--gc-text-bright);
}

.peek-header span {
  color: var(--gc-cyan);
  font-family: var(--font-mono);
  font-size: 13px;
}

.peek-slots {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  flex-wrap: wrap;
  gap: 18px;
}

.peek-actions {
  margin-top: 24px;
  display: flex;
  justify-content: center;
}

.peek-actions .bc-btn {
  padding: 0 20px;
  min-height: 40px;
  border-radius: 8px;
  background: var(--gc-blue);
  color: #fff;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 700;
  border: none;
  transition: background 0.15s ease, transform 0.1s ease;
}

.peek-actions .bc-btn:hover {
  background: #2563eb;
  transform: scale(1.04);
}

.peek-slot {
  position: relative;
  width: 190px;
}

.peek-slot.dragging {
  z-index: 6;
}

.peek-label {
  text-align: center;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--gc-muted);
  margin-bottom: 8px;
}

.peek-stage {
  position: relative;
  width: 190px;
  height: 270px;
  margin: 0 auto;
  pointer-events: auto;
  touch-action: none;
}

.peek-face,
.peek-back {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 14px;
  user-select: none;
  -webkit-user-drag: none;
}

.peek-face {
  z-index: 1;
  box-shadow: 0 16px 24px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  background: #fff;
}

.peek-face-image {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.peek-face-mask {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 40px;
  height: 90px;
  background: #fff;
  border-bottom-right-radius: 14px;
  z-index: 2;
  pointer-events: none;
}

.peek-back {
  z-index: 3;
  cursor: grab;
  transition: transform 90ms linear, opacity 160ms ease;
  object-fit: cover;
  box-shadow: 0 16px 24px rgba(0, 0, 0, 0.5);
}

.peek-slot.peeled .peek-face-mask {
  opacity: 0;
}

.peek-back.peeled {
  cursor: default;
}

/* ── Log / list ─────────────────────────────────────────── */
.log-list {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
  margin-top: 14px;
}

.log-item {
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 13px;
  color: var(--gc-muted);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.log-item strong {
  color: var(--gc-text-bright);
}

.log-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.log-item-subtle {
  margin-top: 4px;
  color: var(--gc-muted);
  font-size: 12px;
  font-family: var(--font-mono);
}

.log-item-actions {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tiny-btn {
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--gc-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--gc-text);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.tiny-btn.primary {
  background: var(--gc-blue);
  border: none;
  color: #fff;
}

/* ── Player profile card (modal) ────────────────────────── */
.player-profile-card {
  width: min(100%, 360px);
}

.player-profile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.player-profile-body {
  margin-top: 14px;
  display: grid;
  justify-items: center;
  gap: 10px;
  text-align: center;
}

.player-profile-avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--gc-border);
  background: rgba(255, 255, 255, 0.05);
}

.player-profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.player-profile-name {
  font-family: var(--font-head);
  font-size: 18px;
  color: var(--gc-text-bright);
}

.player-profile-points {
  color: var(--gc-cyan);
  font-family: var(--font-mono);
  font-size: 16px;
}

.player-profile-location {
  font-size: 13px;
  color: var(--gc-muted);
}

.player-profile-status {
  font-size: 13px;
  color: var(--gc-green);
  font-weight: 700;
}

/* ── Deal card animation ────────────────────────────────── */
.deal-card {
  position: fixed;
  z-index: 25;
  transition: transform 360ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 360ms ease;
  box-shadow: 0 14px 24px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

/* ── Table timer (mobile) ─────────────────────────────────── */
.bc-table-timer {
  display: none;
  margin: 8px auto 0;
  min-width: 60px;
  text-align: center;
  padding: 4px 12px;
  border-radius: 8px;
  background: rgba(13, 32, 53, 0.9);
  border: 1px solid var(--gc-border);
  font-family: var(--font-head);
  font-size: 20px;
  color: var(--gc-cyan);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  width: fit-content;
}

/* ── Mobile controls ────────────────────────────────────── */
.mobile-controls {
  display: none;
}

.mobile-controls-top {
  display: flex;
  align-items: center;
  gap: 8px;
  position: absolute;
  inset: 8px 8px auto 8px;
  z-index: 6;
}

.mobile-top-timer {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  min-width: 80px;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border: 1px solid var(--gc-border);
  border-radius: 8px;
  background: rgba(13, 32, 53, 0.92);
  backdrop-filter: blur(8px);
  font-family: var(--font-head);
  font-size: 18px;
  color: var(--gc-cyan);
}

.mobile-profile {
  margin-left: auto;
  min-height: 34px;
  padding: 5px 10px;
}

.mobile-room-card {
  position: fixed;
  right: 10px;
  bottom: 10px;
  z-index: 6;
  border: 1px solid var(--gc-border);
  border-radius: 12px;
  background: rgba(10, 25, 50, 0.92);
  backdrop-filter: blur(8px);
  box-shadow: var(--gc-shadow-sm);
  padding: 10px 12px;
  width: min(30vw, 260px);
  max-width: 30vw;
  max-height: 50vh;
  overflow: auto;
}

.mobile-room-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.mobile-room-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 11px;
}

.mobile-room-stats div {
  display: grid;
  gap: 2px;
}

.mobile-room-stats span {
  color: var(--gc-muted);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: var(--font-mono);
}

.mobile-room-stats strong {
  color: var(--gc-text-bright);
  font-family: var(--font-mono);
}

.mobile-actions {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

/* ═══════════════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════════════ */

/* ── Tablets and phones (≤900px) ───────────────────────────── */
@media (max-width: 900px) {
  .bc-game {
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
  }

  .bc-table {
    flex: 1;
    width: 100%;
    min-height: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  /* Old mobile controls hidden — sidebar bottom-bar replaces them */
  .mobile-controls {
    display: none !important;
  }

  /* Portrait mode is now supported */
  .orientation-lock {
    display: none !important;
  }

  .table-center {
    transform: translate(-50%, calc(-50% - 100px));
    width: min(85%, 300px);
  }

  .table-center strong,
  .table-center span {
    display: none;
  }

  .table-deck {
    width: 72px;
    height: 100px;
    border-radius: 10px;
  }

  .table-deck::before,
  .table-deck::after { border-radius: 10px; }
  .table-deck::before { transform: translate(-3px, -3px) rotate(-4deg); }
  .table-deck::after { transform: translate(3px, 2px) rotate(4deg); }

  .bc-table-timer:not(.hidden) { display: block; }

  .bc-table-timer {
    font-size: 18px;
    padding: 3px 10px;
  }

  /* ── Profile chip compact ────────────────── */
  .bc-profile-chip {
    min-height: 32px;
    padding: 4px 8px;
    gap: 4px;
  }

  .bc-profile-chip strong {
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80px;
  }

  .bc-profile-chip span {
    font-size: 10px;
    white-space: nowrap;
  }

  .bc-btn-icon {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  /* ── Seats: self ───────────────────────── */
  .seat {
    width: 160px;
  }

  .seat-card { padding: 8px; }
  .bc-avatar { width: 40px; height: 40px; }
  .seat-name { font-size: 12px; }
  .seat-points { font-size: 11px; }
  .seat-status, .seat-delta { font-size: 10px; }
  .seat-delta { margin-top: 4px; }

  .mini-card,
  .empty-card,
  .deal-card {
    width: 44px;
  }

  .hand {
    min-height: 68px;
    gap: 4px;
    margin-top: 6px;
  }

  /* ── Seats: opponents (smaller) ────────── */
  .seat-opponent {
    width: 120px;
  }

  .seat-opponent .seat-card { padding: 6px; }
  .seat-opponent .bc-avatar { width: 30px; height: 30px; }
  .seat-opponent .seat-name { font-size: 10px; }
  .seat-opponent .seat-points { font-size: 9px; }
  .seat-opponent .seat-status { font-size: 9px; }
  .seat-opponent .seat-head { gap: 4px; }
  .seat-opponent .seat-delta { margin-top: 2px; }

  .seat-opponent .mini-card,
  .seat-opponent .empty-card {
    width: 33px;
  }

  .seat-opponent .hand {
    min-height: 50px;
    gap: 3px;
    margin-top: 4px;
  }

  /* ── Peek overlay ──────────────────────── */
  .peek-panel {
    width: min(380px, calc(100% - 16px));
    padding: 12px 10px 14px;
  }

  .peek-slot { width: 108px; }
  .peek-stage {
    width: 108px;
    height: 154px;
  }

  .peek-slots { gap: 8px; }
  .peek-header strong { font-size: 13px; }
  .peek-label { font-size: 10px; margin-bottom: 4px; }
}

/* ── Small phones (≤420px) ─────────────────────────────────── */
@media (max-width: 420px) {
  .seat { width: 140px; }
  .seat-opponent { width: 105px; }

  .seat-opponent .mini-card,
  .seat-opponent .empty-card {
    width: 28px;
  }

  .seat-opponent .hand { min-height: 44px; }

  .mini-card,
  .empty-card,
  .deal-card {
    width: 38px;
  }

  .hand { min-height: 58px; }

  .peek-slot,
  .peek-stage {
    width: 96px;
    height: 136px;
  }
}

/* ── Phone landscape ───────────────────────────────────────── */
@media (orientation: landscape) and (max-width: 932px) and (pointer: coarse) {
  .bc-table {
    padding-top: 0;
  }

  .table-center {
    transform: translate(-50%, calc(-50% - 100px));
    width: min(70%, 280px);
  }

  .seat { width: 150px; }
  .seat-opponent { width: 130px; }
  .bc-avatar { width: 36px; height: 36px; }
  .seat-card { padding: 7px 6px; }

  .mini-card,
  .empty-card,
  .deal-card {
    width: 40px;
  }

  .hand {
    min-height: 64px;
    gap: 4px;
  }

  .seat-opponent .mini-card,
  .seat-opponent .empty-card {
    width: 34px;
  }

  .seat-opponent .hand { min-height: 56px; }

  .peek-panel {
    width: min(680px, calc(100% - 16px));
    padding: 8px 10px 10px;
  }

  .peek-slot,
  .peek-stage {
    width: 120px;
    height: 170px;
  }

  .peek-slots { gap: 10px; }
}
