:root {
  --bg-dark: #05130d;
  --gold: #f8c028;
  --red: #d32f2f;
  --black: #1a1a1a;
  --felt-bg: radial-gradient(ellipse at center, #187352 0%, #0d4631 65%, #072a1d 100%);
  --wood-border: #5a3813;
  --trim-border: #f8c028;
  --room-bg: radial-gradient(circle at center, #102d21 0%, #040e0a 100%);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
}

#app {
  width: 100vw;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--room-bg);
  overflow: hidden;
  position: relative;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.header-bar {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  padding: 8px 14px;
  z-index: 30;
}
.table-badge {
  background: rgba(0,0,0,0.6);
  border: 1px solid var(--gold);
  color: var(--gold);
  font-size: 11px;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 12px;
}

.floating-top-actions {
  position: fixed;
  top: 8px;
  right: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  z-index: 99;
}
.floating-top-actions .icon-btn {
  background: rgba(15, 23, 42, 0.88);
  border: 1.5px solid var(--gold);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.7);
  transition: transform 0.1s;
}
.floating-top-actions .icon-btn:active { transform: scale(0.9); }

.table-area {
  position: relative;
  flex: 1;
  margin: 2px auto;
  width: 96%;
  max-width: 960px;
  border-radius: 200px;
  border: 5px solid var(--wood-border);
  box-shadow: inset 0 0 50px rgba(0,0,0,0.9), 0 0 0 2px var(--trim-border), 0 0 25px rgba(0,0,0,0.8);
  background: var(--felt-bg);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.table-watermark {
  position: absolute;
  color: rgba(248, 192, 40, 0.7);
  font-weight: 900;
  font-size: 12px;
  letter-spacing: 2px;
  pointer-events: none;
  text-align: center;
  background: rgba(0,0,0,0.35);
  padding: 4px 12px;
  border-radius: 16px;
  border: 1px dashed rgba(248, 192, 40, 0.6);
  z-index: 2;
}

.center-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid var(--gold);
  color: var(--gold);
  padding: 5px 14px;
  border-radius: 16px;
  font-size: 11px;
  font-weight: 600;
  z-index: 100;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  text-align: center;
  white-space: nowrap;
  animation: popCenterBanner 0.2s ease-out;
}
@keyframes popCenterBanner {
  0% { transform: translate(-50%, -50%) scale(0.8); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.player-box {
  position: absolute;
  display: none;
  flex-direction: column;
  align-items: center;
  z-index: 10;
  transition: all 0.25s ease-out;
}

.avatar-row {
  display: flex;
  align-items: center;
  gap: 4px;
  position: relative;
  justify-content: center;
}

.avatar-wrap {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #2a3b4c 0%, #0f172a 100%);
  border: 2px solid #d4af37;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  z-index: 2;
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.1s;
}
.avatar-wrap:active { transform: scale(0.92); }

.player-box.active .avatar-wrap {
  border-color: #ffd700;
  box-shadow: 0 0 16px rgba(255, 215, 0, 0.95);
}

.timer-num {
  position: absolute;
  bottom: -4px;
  right: -4px;
  background: #e02f2f;
  color: white;
  font-size: 10px;
  font-weight: bold;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: none;
  align-items: center;
  justify-content: center;
  border: 1.5px solid #fff;
  z-index: 4;
}
.player-box.active .timer-num { display: flex; }

#player-top .timer-num,
#player-right .timer-num {
  right: auto;
  left: -4px;
}

.player-info {
  margin-top: 2px;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid rgba(248, 192, 40, 0.4);
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 9px;
  font-weight: 800;
  color: #fce7a1;
  text-align: center;
  white-space: nowrap;
  max-width: 95px;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: transform 0.1s;
}
.player-info:active { transform: scale(0.92); }

.coin-badge {
  color: #4ade80;
  font-size: 9px;
  display: block;
  font-weight: 900;
}

.opponent-single-card {
  position: relative;
  width: 24px;
  height: 35px;
  background: linear-gradient(135deg, #1e3a8a 0%, #0f172a 100%);
  border: 1.5px solid var(--gold);
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.card-count-num {
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
}

.reveal-board-hand {
  display: none;
  position: absolute;
  z-index: 35;
  pointer-events: none;
}
.reveal-board-hand .card {
  width: 30px !important;
  height: 46px !important;
  padding: 1px 2px !important;
  border-radius: 3px !important;
  box-shadow: 0 2px 5px rgba(0,0,0,0.85) !important;
}
.reveal-board-hand .card .corner-tl {
  top: 1px;
  left: 2px;
}
.reveal-board-hand .card .card-val { 
  font-size: 9.5px !important; 
  font-weight: 900 !important; 
  line-height: 1 !important;
}
.reveal-board-hand .card .card-suit { 
  font-size: 8px !important; 
  line-height: 1 !important;
  margin-top: 1px !important;
}
.reveal-board-hand .card .card-center-suit { font-size: 13px !important; }
.reveal-board-hand .card .court-art-frame { width: 14px !important; height: 22px !important; }

#reveal-top {
  flex-direction: row;
  top: 89px;
  left: 50%;
  transform: translateX(-50%);
}
#reveal-top .card:not(:first-child) {
  margin-left: -17px !important;
}

#reveal-left {
  flex-direction: column;
  left: 80px;
  top: 48%;
  transform: translateY(-50%);
}
#reveal-left .card:not(:first-child) {
  margin-top: -24px !important;
  margin-left: 0 !important;
}

#reveal-right {
  flex-direction: column;
  right: 80px;
  top: 48%;
  transform: translateY(-50%);
}
#reveal-right .card:not(:first-child) {
  margin-top: -24px !important;
  margin-left: 0 !important;
}

.p-top { top: 11px; left: 50%; transform: translateX(-50%); }
.p-top .avatar-row { flex-direction: row; }

.p-left { left: 10px; top: 48%; transform: translateY(-50%); align-items: center; }
.p-left.playing { left: 4px; }
.p-left .avatar-row { flex-direction: row-reverse; }

.p-right { right: 10px; top: 48%; transform: translateY(-50%); align-items: center; }
.p-right.playing { right: 4px; }
.p-right .avatar-row { flex-direction: row; }

.board-center {
  position: absolute;
  width: 100%;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 5;
}
.trick-layer {
  position: absolute;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.3s ease;
}
.trick-layer.under {
  transform: translate(-22px, -16px) scale(0.9);
  filter: brightness(0.8);
  opacity: 0.85;
  z-index: 1;
}
.trick-layer.top {
  transform: translate(0px, 0px) scale(1);
  z-index: 4;
  animation: dropCard 0.25s ease;
}
@keyframes dropCard {
  0% { transform: translateY(-20px) scale(1.2); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
.trick-badge {
  position: absolute;
  bottom: -20px;
  background: rgba(0,0,0,0.85);
  border: 1px solid var(--gold);
  color: var(--gold);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: bold;
  white-space: nowrap;
  z-index: 5;
}

.card {
  width: 48px;
  height: 72px;
  background: #ffffff;
  border-radius: 5px;
  box-shadow: 0 3px 6px rgba(0,0,0,0.4);
  border: 1px solid #c0c0c0;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 2px 3px;
  cursor: pointer;
  flex-shrink: 0;
}
.card.red { color: var(--red); }
.card.black { color: var(--black); }

.corner-tl {
  position: absolute;
  top: 2px;
  left: 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}
.corner-br {
  position: absolute;
  bottom: 2px;
  right: 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  transform: rotate(180deg);
}
.card-val { font-size: 13px; font-weight: 900; }
.card-suit { font-size: 10px; }

.card.card-back {
  background: linear-gradient(135deg, #1e3a8a 0%, #0f172a 100%);
  border: 1.5px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-center-suit {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 22px;
  opacity: 0.85;
}
.court-art-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 26px;
  height: 44px;
  border: 1px solid #1a1a1a;
  border-radius: 2px;
  overflow: hidden;
  background: #fffdf5;
}
.court-art-frame svg { width: 100%; height: 100%; display: block; }

.action-controls {
  position: absolute;
  bottom: 170px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 0;
  margin: 0;
  z-index: 30;
  pointer-events: auto;
  width: max-content;
}
.btn-game {
  border: none;
  border-radius: 8px;
  padding: 7px 16px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 3px 6px rgba(0,0,0,0.5);
  transition: transform 0.1s;
  color: #fff;
}
.btn-game:active { transform: scale(0.95); }
.btn-game.btn-sort {
  background: linear-gradient(180deg, #d97706 0%, #92400e 100%);
  border: 1px solid var(--gold);
}
.btn-game.btn-pass {
  background: linear-gradient(180deg, #4d6872 0%, #293a40 100%);
  border: 1px solid #6b8a96;
}
.btn-game.btn-hint {
  background: linear-gradient(180deg, #0284c7 0%, #0369a1 100%);
  border: 1px solid #38bdf8;
}
.btn-game.btn-play {
  background: linear-gradient(180deg, #22c55e 0%, #15803d 100%);
  border: 1px solid #4ade80;
}
.btn-game:disabled { opacity: 0.35; pointer-events: none; filter: grayscale(0.8); }

.turn-clock {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle, #f59e0b 0%, #b45309 100%);
  border: 2px solid #fff;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 900;
  font-size: 13px;
  flex-shrink: 0;
}

.hand-wrapper {
  position: relative;
  width: 100%;
  height: 98px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 15;
  margin-bottom: 2px;
  padding-top: 18px;
}
.my-cards {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  width: auto;
  max-width: 98%;
}
.my-cards .card {
  width: 52px;
  height: 80px;
  border-radius: 5px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.6);
  transition: transform 0.15s ease, margin 0.2s ease;
}
.my-cards .card:first-child { margin-left: 0 !important; }
.my-cards .card .card-val { font-size: 14px; font-weight: 900; }
.my-cards .card .card-suit { font-size: 11px; }
.my-cards .card .card-center-suit { font-size: 22px; }
.my-cards .card.selected {
  transform: translateY(-16px) !important;
  border: 2px solid var(--gold);
  box-shadow: 0 0 12px rgba(248, 192, 40, 0.95);
}

.p-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: rgba(0,0,0,0.7);
  border-top: 1px solid rgba(248, 192, 40, 0.25);
  z-index: 20;
  position: relative;
}
.p-bottom .left-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.p-bottom .left-meta:active { opacity: 0.85; }
.p-bottom .avatar-wrap {
  width: 36px;
  height: 36px;
  font-size: 18px;
}

.floating-bottom-actions {
  position: fixed;
  bottom: 8px;
  right: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  z-index: 99;
}
.btn-float-action {
  background: rgba(15, 23, 42, 0.88);
  border: 1.5px solid var(--gold);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.7);
  transition: transform 0.1s;
}
.btn-float-action:active { transform: scale(0.9); }

/* KHUNG BANNER THỨ HẠNG VÀ 4 MÀU RIÊNG BIỆT */
.winner-announce-banner {
  position: absolute;
  bottom: 180px;
  left: 50%;
  transform: translateX(-50%) scale(0.8);
  font-size: 14px;
  font-weight: 900;
  padding: 6px 20px;
  border-radius: 22px;
  z-index: 100;
  display: none;
  white-space: nowrap;
  letter-spacing: 0.5px;
  animation: winBannerPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes winBannerPop {
  0% { transform: translateX(-50%) scale(0.5); opacity: 0; }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

.winner-announce-banner.rank-1 {
  background: linear-gradient(180deg, #ffe57f 0%, #d4af37 60%, #996515 100%);
  color: #1a0f00;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6), 0 0 20px rgba(248, 192, 40, 0.85);
  border: 1.5px solid #fff;
}

.winner-announce-banner.rank-2 {
  background: linear-gradient(180deg, #e0f2fe 0%, #94a3b8 55%, #475569 100%);
  color: #0f172a;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6), 0 0 20px rgba(56, 189, 248, 0.7);
  border: 1.5px solid #f8fafc;
}

.winner-announce-banner.rank-3 {
  background: linear-gradient(180deg, #fed7aa 0%, #d97706 60%, #92400e 100%);
  color: #fff;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6), 0 0 20px rgba(245, 158, 11, 0.7);
  border: 1.5px solid #fff7ed;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.winner-announce-banner.rank-4 {
  background: linear-gradient(180deg, #f87171 0%, #dc2626 55%, #7f1d1d 100%);
  color: #fff;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.7), 0 0 20px rgba(239, 68, 68, 0.8);
  border: 1.5px solid #fecaca;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* HIỆU ỨNG SÁNG ĐÈN CHỚP NEON CHO LÁ BÀI BỊ THÚI */
.card.penalty-card {
  border: 2px solid #ef4444 !important;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.95), 0 0 25px rgba(220, 38, 38, 0.8) !important;
  animation: penaltyCardPulse 0.8s infinite alternate !important;
  z-index: 99 !important;
}

@keyframes penaltyCardPulse {
  0% {
    transform: translateY(0px) scale(1);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.7);
  }
  100% {
    transform: translateY(-8px) scale(1.08);
    box-shadow: 0 0 20px rgba(255, 0, 0, 1), 0 0 35px rgba(255, 68, 68, 0.9);
  }
}

/* HUY HIỆU TRÊN ĐẦU AVATAR ĐỒNG BỘ 4 MÀU */
.rank-badge {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 12px;
  z-index: 25;
  white-space: nowrap;
  box-shadow: 0 3px 8px rgba(0,0,0,0.7);
  letter-spacing: 0.3px;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.rank-badge.rank-1 {
  background: linear-gradient(180deg, #ffe57f 0%, #d4af37 60%, #996515 100%) !important;
  color: #1a0f00 !important;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.7), 0 0 10px rgba(248, 192, 40, 0.8) !important;
  border: 1px solid #fff !important;
}

.rank-badge.rank-2 {
  background: linear-gradient(180deg, #e0f2fe 0%, #94a3b8 55%, #475569 100%) !important;
  color: #0f172a !important;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.7), 0 0 10px rgba(56, 189, 248, 0.7) !important;
  border: 1px solid #f8fafc !important;
}

.rank-badge.rank-3 {
  background: linear-gradient(180deg, #fed7aa 0%, #d97706 60%, #92400e 100%) !important;
  color: #fff !important;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.7), 0 0 10px rgba(245, 158, 11, 0.7) !important;
  border: 1px solid #fff7ed !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8) !important;
}

.rank-badge.rank-4 {
  background: linear-gradient(180deg, #f87171 0%, #dc2626 55%, #7f1d1d 100%) !important;
  color: #fff !important;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.7), 0 0 10px rgba(239, 68, 68, 0.8) !important;
  border: 1px solid #fecaca !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8) !important;
}

.ready-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #059669;
  border: 1.5px solid #fff;
  box-shadow: 0 0 10px rgba(0,0,0,0.8);
  color: #fff;
  font-size: 9px;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 8px;
  z-index: 15;
  white-space: nowrap;
  pointer-events: none;
  animation: passPopCenter 0.15s ease-out;
}

.overlay-screen {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.85);
  display: flex; 
  align-items: center; 
  justify-content: center;
  z-index: 999;
  padding: 10px;
  overflow-y: auto;
}
.modal-box {
  background: #0f241c;
  border: 2px solid var(--gold);
  border-radius: 16px;
  padding: 16px;
  text-align: center;
  max-width: 390px;
  width: 95%;
  max-height: 94dvh;
  overflow-y: auto;
  color: #fff;
  box-shadow: 0 0 30px rgba(0,0,0,0.9);
}

.casino-modal {
  background: radial-gradient(circle at top, #133a29 0%, #06150f 100%) !important;
  border: 2px solid #d4af37 !important;
  box-shadow: 0 10px 40px rgba(0,0,0,0.9), inset 0 0 20px rgba(212, 175, 55, 0.15) !important;
  border-radius: 20px !important;
  padding: 22px 18px !important;
  position: relative;
}

.casino-title-wrap {
  margin-bottom: 12px;
  text-align: center;
}
.casino-title {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 1.5px;
  background: linear-gradient(180deg, #ffe57f 0%, #d4af37 60%, #aa7c11 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-transform: uppercase;
}
.casino-sub {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 2px;
}

.avatar-display-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 12px;
}
.main-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #2a3b4c 0%, #09131d 100%);
  border: 2.5px solid var(--gold);
  box-shadow: 0 0 15px rgba(248, 192, 40, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.main-avatar:active { transform: scale(0.95); }

.stylish-input-group {
  position: relative;
  width: 100%;
  margin-bottom: 12px;
}
.stylish-input-group input {
  width: 100%;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(248, 192, 40, 0.4);
  border-radius: 12px;
  padding: 10px 42px 10px 14px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  outline: none;
  transition: border-color 0.2s;
}
.stylish-input-group input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 8px rgba(248, 192, 40, 0.3);
}
.btn-inside-random {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(248, 192, 40, 0.15);
  border: 1px solid var(--gold);
  color: var(--gold);
  border-radius: 8px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
}

.action-tabs {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 12px;
}

.join-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.join-row input {
  flex: 1;
  min-width: 0;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 10px 8px;
  color: #fff;
  text-align: center;
  font-weight: bold;
  font-size: 13px;
  letter-spacing: 1px;
  box-sizing: border-box;
}
.btn-join-action {
  background: linear-gradient(180deg, #10b981 0%, #047857 100%);
  border: 1px solid #34d399;
  color: #fff;
  font-weight: 800;
  border-radius: 12px;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1;
  box-sizing: border-box;
}

.diff-selector-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(0,0,0,0.45);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.1);
}
.diff-opt-btn {
  flex: 1;
  border: 1px solid transparent;
  background: transparent;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 800;
  padding: 5px 0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.diff-opt-btn.active {
  background: linear-gradient(180deg, #38bdf8 0%, #0284c7 100%);
  color: #fff;
  border-color: #7dd3fc;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.5);
}

.bot-mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.btn-bot-action {
  background: linear-gradient(180deg, #3b82f6 0%, #1d4ed8 100%);
  border: 1px solid #60a5fa;
  color: #fff;
  font-weight: 800;
  border-radius: 10px;
  padding: 8px 4px;
  cursor: pointer;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  transition: transform 0.1s;
}
.btn-bot-action:active { transform: scale(0.95); }

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  max-height: 85px;
  overflow-y: auto;
  padding: 6px;
  background: rgba(0,0,0,0.3);
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 8px;
  width: 100%;
}
.avatar-option {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #1e293b;
  border: 1.5px solid rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
}
.avatar-option.selected {
  border-color: var(--gold);
  box-shadow: 0 0 8px var(--gold);
  background: #334155;
}
.theme-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
}
.theme-card {
  border-radius: 12px;
  padding: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
}
.theme-card.active { border-color: var(--gold); box-shadow: 0 0 10px var(--gold); }
.theme-preview-pill {
  width: 100%;
  height: 36px;
  border-radius: 18px;
  margin-bottom: 4px;
}

.emote-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px;
  background: rgba(0,0,0,0.3);
  border-radius: 12px;
  margin-bottom: 8px;
}
.emote-item {
  font-size: 30px;
  cursor: pointer;
  transition: transform 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}
.emote-item:active { transform: scale(1.35); }

.chat-quick-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 160px;
  overflow-y: auto;
  margin: 8px 0;
  text-align: left;
  padding-right: 4px;
}
.chat-quick-item {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 6px 9px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.chat-quick-item:active {
  background: rgba(248, 192, 40, 0.2);
  border-color: var(--gold);
}

.btn-big {
  background: linear-gradient(180deg, #f7c948 0%, #b8860b 100%);
  color: #1a1202;
  padding: 8px 18px;
  border-radius: 25px;
  font-weight: 800;
  font-size: 13px;
  border: none;
  cursor: pointer;
  width: 100%;
  margin-top: 6px;
}
.btn-outline {
  background: linear-gradient(180deg, #10b981 0%, #047857 100%);
  color: #ffffff;
  border: 1px solid #34d399;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
  padding: 8px 18px;
  border-radius: 25px;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  width: 100%;
  margin-top: 6px;
}

.result-list {
  margin: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  font-size: 12px;
}
.result-item {
  display: flex;
  justify-content: space-between;
  background: rgba(255,255,255,0.06);
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  align-items: center;
}

.toast-banner {
  position: absolute;
  top: 14%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.85);
  border: 1px solid var(--gold);
  color: var(--gold);
  padding: 5px 14px;
  border-radius: 16px;
  font-size: 11px;
  font-weight: bold;
  z-index: 40;
  pointer-events: none;
}

.flying-card {
  position: fixed;
  width: 32px;
  height: 48px;
  background: linear-gradient(135deg, #1e3a8a 0%, #0f172a 100%);
  border: 1.5px solid var(--gold);
  border-radius: 4px;
  z-index: 9999;
  pointer-events: none;
  transition: all 0.22s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.chat-text-bubble {
  position: absolute;
  background: rgba(15, 23, 42, 0.95);
  border: 1.5px solid var(--gold);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 5px 9px;
  border-radius: 12px;
  white-space: normal;
  width: max-content;
  max-width: 170px;
  z-index: 50;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.9);
  word-break: break-word;
  line-height: 1.3;
  animation: popInSide 0.2s ease-out;
}

#player-left .chat-text-bubble { top: 0; left: 100%; margin-left: 8px; }
#player-right .chat-text-bubble { top: 0; right: 100%; margin-right: 8px; }
#player-top .chat-text-bubble {
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 6px;
  animation: popInCenter 0.2s ease-out;
}

@keyframes popInCenter {
  0% { transform: translateX(-50%) scale(0.7); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
@keyframes popInSide {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.chat-emote-bubble {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(1.25);
  font-size: 28px;
  z-index: 50;
  pointer-events: none;
  filter: drop-shadow(0 2px 5px rgba(0,0,0,0.8));
  animation: emoteBounce 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes emoteBounce {
  0% { transform: translate(-50%, -50%) scale(0.3); }
  50% { transform: translate(-50%, -50%) scale(1.4); }
  100% { transform: translate(-50%, -50%) scale(1.25); }
}

.floating-coin {
  position: absolute;
  top: -15px;
  left: 50%;
  transform: translateX(-50%);
  font-weight: 900;
  font-size: 13px;
  animation: floatUp 1.2s ease-out forwards;
  pointer-events: none;
  z-index: 25;
}
.floating-coin.plus { color: #4ade80; }
.floating-coin.minus { color: #f87171; }
@keyframes floatUp {
  0% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -30px); }
}

.player-status-pass {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(220, 38, 38, 0.95);
  border: 1.5px solid #fff;
  box-shadow: 0 0 10px rgba(0,0,0,0.9);
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  padding: 2px 7px;
  border-radius: 8px;
  z-index: 60;
  white-space: nowrap;
  pointer-events: none;
  animation: passPopCenter 0.15s ease-out;
}

@keyframes passPopCenter {
  0% { transform: translate(-50%, -50%) scale(0.6); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

body.theme-macau { --felt-bg: radial-gradient(ellipse at center, #8a1515 0%, #2b0404 100%); --room-bg: radial-gradient(circle at center, #3d0707 0%, #110000 100%); }
body.theme-navy { --felt-bg: radial-gradient(ellipse at center, #133b63 0%, #04101e 100%); --room-bg: radial-gradient(circle at center, #0e2033 0%, #02070d 100%); }
body.theme-amber { --felt-bg: radial-gradient(ellipse at center, #573a0e 0%, #170e01 100%); --room-bg: radial-gradient(circle at center, #2e1d04 0%, #0b0701 100%); }

.interaction-panel {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(248, 192, 40, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.interaction-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.interaction-items-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  width: 100%;
  padding: 4px 0;
}
.interact-btn {
  background: radial-gradient(circle at 35% 35%, #1e293b 0%, #09131d 100%);
  border: 1.5px solid rgba(248, 192, 40, 0.4);
  border-radius: 10px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0,0,0,0.6);
  transition: all 0.15s ease;
}
.interact-btn:hover {
  border-color: var(--gold);
  transform: translateY(-2px) scale(1.08);
  box-shadow: 0 0 10px rgba(248, 192, 40, 0.7);
}
.interact-btn:active {
  transform: scale(0.92);
}

.flying-interact-item {
  position: fixed;
  z-index: 999999;
  pointer-events: none;
  font-size: 34px;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.8));
  transition: left 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
              top 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
              transform 0.6s ease-in-out;
}

.impact-effect {
  position: fixed;
  z-index: 999999;
  pointer-events: none;
  font-size: 46px;
  transform: translate(-50%, -50%) scale(0.3);
  animation: impactSplatter 0.9s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
@keyframes impactSplatter {
  0% { transform: translate(-50%, -50%) scale(0.3) rotate(0deg); opacity: 1; }
  25% { transform: translate(-50%, -50%) scale(1.4) rotate(-15deg); opacity: 1; }
  60% { transform: translate(-50%, -50%) scale(1.1) rotate(10deg); opacity: 0.95; }
  100% { transform: translate(-50%, -50%) scale(1.6) translateY(20px); opacity: 0; }
}

@media (orientation: landscape) {
  #app { padding: 0 max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left)); }
  .table-area {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    height: 90%; width: 98%;
    margin: 0;
  }
  .board-center { margin-top: -25px; }
  .hand-wrapper {
    position: absolute;
    bottom: 0px; left: 0; right: 0;
    height: 96px; margin-bottom: 0; padding-top: 0;
    pointer-events: none; z-index: 15;
  }
  .my-cards { max-width: 90%; pointer-events: auto; }
  .my-cards .card { width: 58px; height: 88px; }
  .action-controls {
    position: absolute;
    bottom: 100px; left: 50%;
    transform: translateX(-50%);
    padding: 0; margin-bottom: 0; z-index: 30;
  }

  .winner-announce-banner {
    bottom: 165px !important;
    transform: translateX(-50%) scale(0.85);
  }

  .p-bottom {
    position: absolute;
    bottom: 6px; left: 8px;
    background: rgba(0,0,0,0.65);
    border: 1px solid rgba(248, 192, 40, 0.4);
    padding: 3px 8px; border-radius: 20px; z-index: 25;
  }
  .floating-top-actions { top: 8px; right: 12px; }
  .floating-bottom-actions { bottom: 8px; right: 12px; }
  .overlay-screen { padding: 6px; align-items: center; }
  .modal-box { max-width: 440px; max-height: 96dvh; padding: 8px 14px; }
  .modal-box h2, .modal-box h3 { font-size: 14px; margin-bottom: 2px !important; }
  .chosen-avatar-preview { width: 38px; height: 38px; font-size: 20px; margin: 0 auto 2px auto !important; }
  #profId { margin-bottom: 3px !important; font-size: 9px !important; }
  #profAvatarPickerWrap { margin-bottom: 4px !important; }
  .avatar-grid { max-height: 58px; gap: 4px; padding: 3px; margin-bottom: 4px; }
  .avatar-option { width: 25px; height: 25px; font-size: 13px; }
  .result-list { margin: 4px 0; gap: 4px; font-size: 10px; }
  .result-item { padding: 4px 8px; }
  .btn-big, .btn-outline { padding: 6px 12px; font-size: 11px; margin-top: 4px; }
  .chat-quick-list { max-height: 115px; gap: 3px; }
  .chat-quick-item { padding: 4px 8px; font-size: 10px; }
  .emote-grid { gap: 6px; padding: 6px; margin-bottom: 4px; }
  .emote-item { font-size: 24px; padding: 2px; }
  .theme-grid { gap: 6px; margin: 6px 0; }
  .theme-preview-pill { height: 26px; }
  .interaction-items-grid { gap: 4px; }
  .interact-btn { height: 34px; font-size: 18px; border-radius: 8px; }
}

#customChatInput {
  flex: 1;
  background: rgba(0, 0, 0, 0.5);
  border: 1.5px solid rgba(248, 192, 40, 0.4);
  border-radius: 10px;
  padding: 10px 14px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  outline: none;
  transition: all 0.2s;
  box-sizing: border-box;
}

#customChatInput:focus {
  border-color: var(--gold);
  box-shadow: 0 0 8px rgba(248, 192, 40, 0.4);
  background: rgba(0, 0, 0, 0.7);
}

#customChatInput::placeholder {
  color: #94a3b8;
  font-size: 12px;
}

#chatModal form button[type="submit"] {
  height: auto;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}
/* Chỉ nhích duy nhất nút Ván Tiếp Theo lên cao */
#hostStartBtn {
  transform: translateY(-20px); /* Đẩy nút nhích lên 20px (tăng/giảm số này tùy ý) */
}

#hostStartBtn:active {
  transform: translateY(-20px) scale(0.95); /* Giữ hiệu ứng bấm lún mượt mà */
}
@media (orientation: landscape) {
  /* Chỉnh riêng nút SẴN SÀNG ở màn hình ngang */
  #readyBtn {
    transform: translateY(11px) !important; /* Tăng số để hạ xuống, giảm hoặc đặt số âm để nâng lên */
  }
  #readyBtn:active {
    transform: translateY(20px) scale(0.95) !important;
  }

  /* Nút Ván Tiếp Theo */
  #hostStartBtn {
    transform: translateY(11px) !important;
  }
  #hostStartBtn:active {
    transform: translateY(11px) scale(0.95) !important;
  }

  /* Cụm nút khi đánh bài */
  #gameControls {
    bottom: 106px;
  }

  /* Chữ kết quả */
  .winner-announce-banner {
    bottom: 102px !important;
  }
}