/* ========================================================
   🏁 CỜ ĐAM TRÀ SỮA (CỜ VẬT) - MINIGAME TIỆM TRÀ MƠ ƯỚC
   Bàn cờ 8x8 chuẩn: Quân Trân Châu Đen vs Quân Thạch Dừa Hoàng Kim
   Phong cấp: Đại Trân Châu Vương 👑
   ======================================================== */

.codam-modal {
  position: fixed;
  inset: 0;
  background: rgba(30, 15, 8, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 8px;
  overflow-y: auto;
  box-sizing: border-box;
}

.codam-modal[hidden] {
  display: none !important;
}

.codam-card {
  background: #fdfbf7;
  border: 3.5px solid #854d0e;
  border-radius: 22px;
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.5);
  max-width: min(540px, 98vw);
  width: 100%;
  max-height: calc(100vh - 16px);
  max-height: calc(100dvh - 16px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 14px 16px;
  box-sizing: border-box;
  font-family: inherit;
  color: #3b2214;
  position: relative;
  display: flex;
  flex-direction: column;
  animation: codamPop 0.25s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes codamPop {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Header */
.codam-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px dashed #e2cbb2;
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.codam-title-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.codam-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 900;
  color: #78350f;
  letter-spacing: 0.3px;
}

.codam-subtitle {
  font-size: 0.75rem;
  color: #92400e;
  font-weight: 600;
}

.codam-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.codam-head-btn {
  background: #fef3c7;
  border: 1.5px solid #fde68a;
  border-radius: 10px;
  padding: 5px 9px;
  font-size: 0.8rem;
  font-weight: 800;
  color: #92400e;
  cursor: pointer;
  transition: all 0.15s;
}

.codam-head-btn:hover {
  background: #fde68a;
  transform: scale(1.05);
}

.codam-head-close {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
  padding: 4px 10px;
  font-size: 0.95rem;
}

.codam-head-close:hover {
  background: #fca5a5;
}

/* Status Bar */
.codam-status-bar {
  background: #fffbeb;
  border: 2px solid #fde68a;
  border-radius: 12px;
  padding: 7px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #78350f;
  text-align: center;
  margin-bottom: 8px;
  line-height: 1.45;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
}

.codam-bet-indicator {
  font-size: 0.74rem;
  background: #fef3c7;
  border: 1.5px solid #f59e0b;
  color: #b45309;
  padding: 2px 7px;
  border-radius: 8px;
  font-weight: 800;
}

/* Player Info Bars */
.codam-players-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.codam-player-card {
  flex: 1;
  background: #fff;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  position: relative;
}

.codam-player-card.active-turn {
  border-color: #f59e0b;
  background: #fffbeb;
  box-shadow: 0 0 0 2.5px rgba(245, 158, 11, 0.4), 0 3px 8px rgba(245, 158, 11, 0.15);
  transform: translateY(-1px);
}

.codam-p-avatar {
  font-size: 1.7rem;
  line-height: 1;
  flex: none;
}

.codam-p-info {
  flex: 1;
  min-width: 0;
}

.codam-p-name {
  font-size: 0.8rem;
  font-weight: 800;
  color: #451a03;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.codam-p-stats {
  font-size: 0.74rem;
  font-weight: 700;
  color: #b45309;
  margin-top: 1px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.codam-p-badge {
  font-size: 0.68rem;
  padding: 1px 5px;
  border-radius: 6px;
  font-weight: 800;
}

.codam-badge-black {
  background: #27272a;
  color: #f4f4f5;
}

.codam-badge-gold {
  background: #fef08a;
  color: #854d0e;
  border: 1px solid #ca8a04;
}

/* Board Outer */
.codam-board-outer {
  background: #78350f;
  border: 4px solid #451a03;
  border-radius: 16px;
  padding: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35), inset 0 2px 6px rgba(255, 255, 255, 0.15);
  margin-bottom: 8px;
  user-select: none;
  display: flex;
  justify-content: center;
}

.codam-board-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 2px;
  width: 100%;
  max-width: 440px;
  aspect-ratio: 1 / 1;
  background: #451a03;
  border-radius: 10px;
  overflow: hidden;
}

/* Cells */
.codam-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  user-select: none;
}

.codam-cell.light {
  background: #fef3c7;
}

.codam-cell.dark {
  background: #92400e;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.25);
}

.codam-cell.selected-origin {
  background: #b45309 !important;
  box-shadow: inset 0 0 0 2.5px #38bdf8 !important;
}

/* Move Target Markers */
.codam-cell.valid-move {
  cursor: pointer;
}

.codam-cell.valid-move::after {
  content: '';
  position: absolute;
  width: 32%;
  height: 32%;
  border-radius: 50%;
  background: rgba(34, 197, 94, 0.85);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.9);
  pointer-events: none;
  animation: moveDotPulse 1.2s infinite ease-in-out;
}

@keyframes moveDotPulse {
  0% { transform: scale(0.85); opacity: 0.7; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.85); opacity: 0.7; }
}

.codam-cell.valid-capture {
  cursor: pointer;
}

.codam-cell.valid-capture::after {
  content: '';
  position: absolute;
  width: 42%;
  height: 42%;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.88);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.95);
  border: 2px solid #fff;
  pointer-events: none;
  animation: captureRingPulse 0.9s infinite alternate;
}

@keyframes captureRingPulse {
  from { transform: scale(0.9); opacity: 0.8; }
  to { transform: scale(1.2); opacity: 1; }
}

/* Pieces */
.codam-piece {
  width: 82%;
  height: 82%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.18, 0.89, 0.32, 1.28), box-shadow 0.15s;
  box-sizing: border-box;
  font-size: 1.15rem;
  line-height: 1;
}

.codam-piece:hover {
  transform: scale(1.08);
}

.codam-piece.selected {
  transform: scale(1.12);
  box-shadow: 0 0 0 3px #38bdf8, 0 6px 14px rgba(56, 189, 248, 0.7) !important;
}

.codam-piece.can-capture-alert {
  animation: pieceCaptureAlert 0.85s infinite alternate ease-in-out;
}

@keyframes pieceCaptureAlert {
  from {
    transform: scale(1);
    box-shadow: 0 0 0 2px #ef4444, 0 3px 8px rgba(239, 68, 68, 0.5);
  }
  to {
    transform: scale(1.08);
    box-shadow: 0 0 0 3.5px #f97316, 0 6px 14px rgba(249, 115, 22, 0.8);
  }
}

/* Quân Trân Châu Đen (Black Boba) */
.codam-piece-black {
  background: radial-gradient(circle at 35% 30%, #52525b 0%, #27272a 45%, #09090b 100%);
  border: 2px solid #71717a;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.6), inset 0 2px 4px rgba(255, 255, 255, 0.25);
  color: #fff;
}

/* Quân Thạch Dừa Hoàng Kim (Golden Jelly) */
.codam-piece-gold {
  background: radial-gradient(circle at 35% 30%, #fef08a 0%, #eab308 50%, #a16207 100%);
  border: 2px solid #fde047;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.7);
  color: #78350f;
}

/* Quân Vua (King 👑) */
.codam-piece.king {
  font-size: 1.25rem;
}

.codam-piece.king::before {
  content: '👑';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.15rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.codam-piece-black.king {
  border-color: #fbbf24;
  box-shadow: 0 4px 10px rgba(0,0,0,0.7), 0 0 0 2px #f59e0b, inset 0 2px 4px rgba(255, 255, 255, 0.3);
}

.codam-piece-gold.king {
  border-color: #fff;
  box-shadow: 0 4px 10px rgba(0,0,0,0.5), 0 0 0 2.5px #ea580c, inset 0 2px 4px rgba(255, 255, 255, 0.8);
}

/* Footer & Controls */
.codam-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.codam-rule-tip {
  font-size: 0.74rem;
  color: #78350f;
  background: #fef3c7;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid #fde68a;
  flex: 1;
}

.codam-btn-action {
  background: #f1f5f9;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.76rem;
  font-weight: 800;
  color: #475569;
  cursor: pointer;
  flex: none;
}

.codam-btn-action:hover {
  background: #e2e8f0;
  color: #1e293b;
}

/* ===== MÀN HÌNH ĐẶT CƯỢC (BETTING SCREEN) ===== */
.codam-bet-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.codam-bet-opponent-card {
  background: linear-gradient(135deg, #fef3c7, #fed7aa);
  border: 2px solid #f97316;
  border-radius: 16px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.15);
}

.codam-bet-avatar {
  font-size: 2.8rem;
  line-height: 1;
  flex: none;
}

.codam-bet-opp-info {
  flex: 1;
  min-width: 0;
}

.codam-bet-opp-tag {
  font-size: 0.68rem;
  font-weight: 900;
  color: #ea580c;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.codam-bet-opp-name {
  font-size: 1.05rem;
  font-weight: 900;
  color: #431407;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.codam-bet-opp-badge {
  font-size: 0.74rem;
  font-weight: 700;
  color: #c2410c;
  margin-top: 1px;
}

.codam-bet-opp-quote {
  font-size: 0.78rem;
  font-style: italic;
  color: #7c2d12;
  margin-top: 3px;
  background: rgba(255, 255, 255, 0.6);
  padding: 3px 8px;
  border-radius: 8px;
  display: inline-block;
}

.codam-btn-reroll-opp {
  background: #fff;
  border: 1.5px solid #ea580c;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 800;
  color: #ea580c;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  flex: none;
  box-shadow: 0 2px 5px rgba(0,0,0,0.08);
}

.codam-btn-reroll-opp:hover {
  background: #ffedd5;
  transform: scale(1.05);
}

/* Khung chọn tiền cược */
.codam-bet-form-card {
  background: #fff;
  border: 2px solid #e2cbb2;
  border-radius: 16px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}




.codam-bet-wallet-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 800;
  color: #78350f;
  background: #fffbeb;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid #fde68a;
}

.codam-bet-label {
  font-size: 0.82rem;
  font-weight: 800;
  color: #78350f;
}

.codam-bet-chips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 6px;
}

.codam-bet-chip {
  background: #fefce8;
  border: 1.5px solid #fef08a;
  border-radius: 10px;
  padding: 8px 4px;
  font-size: 0.8rem;
  font-weight: 800;
  color: #854d0e;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}

.codam-bet-chip:hover:not(:disabled) {
  background: #fef08a;
  border-color: #eab308;
  transform: translateY(-1px);
}

.codam-bet-chip.active {
  background: #f59e0b;
  border-color: #d97706;
  color: #fff;
  box-shadow: 0 3px 8px rgba(217, 119, 6, 0.35);
  transform: translateY(-1px);
}

.codam-bet-chip:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.codam-bet-preview-box {
  background: #fbf7ee;
  border: 1.5px dashed #ca8a04;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.82rem;
  line-height: 1.6;
  color: #78350f;
}

.codam-btn-start-game {
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  border: none;
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 0.95rem;
  font-weight: 900;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(234, 88, 12, 0.4);
  transition: all 0.15s;
  text-align: center;
  letter-spacing: 0.3px;
}

.codam-btn-start-game:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(234, 88, 12, 0.5);
}

/* ===== MÀN HÌNH OẲN TÙ TÌ (RPS) ===== */
.codam-rps-box {
  background: #fff;
  border: 2px solid #e2cbb2;
  border-radius: 16px;
  padding: 16px 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.codam-rps-title {
  font-size: 1.05rem;
  font-weight: 900;
  color: #78350f;
}

.codam-rps-sub {
  font-size: 0.82rem;
  color: #92400e;
  max-width: 380px;
  line-height: 1.5;
}

.codam-rps-choices {
  display: flex;
  justify-content: center;
  gap: 14px;
  width: 100%;
  max-width: 360px;
}

.codam-rps-btn {
  flex: 1;
  background: #fffbeb;
  border: 2.5px solid #fde68a;
  border-radius: 16px;
  padding: 12px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.codam-rps-btn:hover {
  background: #fef3c7;
  border-color: #f59e0b;
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 6px 15px rgba(245, 158, 11, 0.25);
}

.codam-rps-ic {
  font-size: 2.4rem;
  line-height: 1;
}

.codam-rps-txt {
  font-size: 0.85rem;
  font-weight: 900;
  color: #78350f;
}

/* Màn hình Chọn Quân (sau khi thắng Oẳn Tù Tì) */
.codam-side-picker-box {
  background: #fff;
  border: 2px solid #e2cbb2;
  border-radius: 16px;
  padding: 16px 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.codam-side-choices {
  display: flex;
  justify-content: center;
  gap: 12px;
  width: 100%;
}

.codam-side-btn {
  flex: 1;
  border-radius: 14px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.codam-side-btn.black {
  background: #27272a;
  border: 2.5px solid #71717a;
  color: #fff;
}

.codam-side-btn.gold {
  background: #fef08a;
  border: 2.5px solid #ca8a04;
  color: #78350f;
}

.codam-side-btn:hover {
  transform: translateY(-2px) scale(1.04);
}

/* Nút đấu tiếp khi ván kết thúc */
.codam-btn-next-match {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  border: none;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 0.86rem;
  font-weight: 900;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(22, 163, 74, 0.35);
  margin-top: 4px;
}

.codam-btn-next-match:hover {
  transform: scale(1.04);
}

/* Responsive Mobile */
@media (max-width: 480px) {
  .codam-card {
    padding: 10px 10px 14px;
  }
  .codam-title {
    font-size: 1.05rem;
  }
  .codam-board-grid {
    max-width: 340px;
  }
  .codam-piece {
    font-size: 0.95rem;
  }
  .codam-piece.king::before {
    font-size: 0.95rem;
  }
  .codam-bet-avatar {
    font-size: 2.3rem;
  }
}
