.bg-wrap {
  /* position: relative;
  max-width: 480px; */
  margin: 20px auto;
  padding: 20px;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 20px;
  box-shadow: 
    0 20px 40px rgba(102, 126, 234, 0.3),
    0 8px 16px rgba(0, 0, 0, 0.1);
  
  /* Tối ưu hóa rendering */
  contain: layout style paint;
  will-change: auto;
  position: relative;
  overflow: hidden;
}

.bg-wrap::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.05) 100%);
  border-radius: 20px;
  pointer-events: none;
  z-index: 0;
}

.bg-wrap > * {
  position: relative;
  z-index: 1;
}

.bg-title {
  margin-bottom: 20px;
  font-weight: 700;
  font-size: 24px;
  color: white;
  text-align: center;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
  letter-spacing: -0.5px;
}

.bg-grid{
  display:flex;
  flex-wrap:nowrap;
  gap:12px;
  width:100%;
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
  padding: 10px;
  background: rgba(255,255,255,0.1);
  border-radius: 16px;
  backdrop-filter: blur(10px);
  
  /* Tối ưu hóa scrolling */
  scroll-behavior: smooth;
  contain: layout;
}
.bg-grid .bg-cell{
  flex: 0 0 var(--cell-size, 96px);
  width: var(--cell-size, 96px);
  height: var(--cell-size, 96px);
}

/* PC: chia đều chiều ngang */
@media (min-width: 1024px) {
  .bg-grid .bg-cell {
    flex: 1;
    /* mỗi ô chiếm đều */
    aspect-ratio: 1/1;
    /* vẫn giữ vuông */
  }
}

/* Mobile: để cuộn ngang thay vì dồn ô nhỏ lại */
@media (max-width: 1023.98px) {
  .bg-grid {
    flex-wrap: wrap;
    gap: 0;
    -webkit-overflow-scrolling: touch;
  }

  .bg-grid .bg-cell {
    flex: 0 0 96px;
    /* hoặc 120px tuỳ bạn */
    height: 96px;
  }
}

/* Ô game: DÙNG CSS VARIABLE --bg cho ảnh nền */
.bg-cell {
  position: relative;
  border: 3px solid rgba(255,255,255,0.3);
  border-radius: 16px;
  cursor: pointer;
  font-size: 40px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;

  background-image: var(--bg, linear-gradient(135deg, rgba(255,255,255,0.9) 0%, rgba(255,255,255,0.7) 100%));
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  
  /* Đảm bảo hình ảnh hiển thị đẹp */
  position: relative;
  overflow: hidden;

  /* Tối ưu hóa transitions - chỉ animate những thuộc tính cần thiết */
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Tối ưu hóa rendering */
  will-change: transform;
  transform: translateZ(0); /* Force hardware acceleration */
  backface-visibility: hidden;
  
  /* Modern shadow */
  box-shadow: 
    0 4px 12px rgba(0,0,0,0.15),
    0 2px 4px rgba(0,0,0,0.1),
    inset 0 1px 0 rgba(255,255,255,0.2);
}

.bg-cell:hover {
  transform: translateZ(0) translateY(-2px) scale(1.02);
  box-shadow: 
    0 8px 20px rgba(0,0,0,0.2),
    0 4px 8px rgba(0,0,0,0.15),
    inset 0 1px 0 rgba(255,255,255,0.3);
  border-color: rgba(255,255,255,0.5);
}

.bg-cell.revealed.safe {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-color: #10b981;
  color: white;
  animation: bg-safe-reveal 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.bg-cell.revealed.safe::before {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2) 0%, rgba(5, 150, 105, 0.1) 100%);
}

.bg-cell.revealed.safe .bg-cell-face {
  background: rgba(16, 185, 129, 0.8);
  color: white;
}

.bg-cell.revealed.boom {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  border-color: #ef4444;
  color: white;
  animation: bg-boom-reveal 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.bg-cell.revealed.boom::before {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.2) 0%, rgba(220, 38, 38, 0.1) 100%);
}

.bg-cell.revealed.boom .bg-cell-face {
  background: rgba(239, 68, 68, 0.8);
  color: white;
}

@keyframes bg-safe-reveal {
  0% {
    transform: translateZ(0) scale(0.8) rotate(-5deg);
    opacity: 0;
  }
  50% {
    transform: translateZ(0) scale(1.1) rotate(2deg);
  }
  100% {
    transform: translateZ(0) scale(1) rotate(0deg);
    opacity: 1;
  }
}

@keyframes bg-boom-reveal {
  0% {
    transform: translateZ(0) scale(0.8) rotate(5deg);
    opacity: 0;
  }
  25% {
    transform: translateZ(0) scale(1.2) rotate(-3deg);
  }
  50% {
    transform: translateZ(0) scale(0.9) rotate(2deg);
  }
  75% {
    transform: translateZ(0) scale(1.1) rotate(-1deg);
  }
  100% {
    transform: translateZ(0) scale(1) rotate(0deg);
    opacity: 1;
  }
}

.bg-cell:active {
  transform: translateZ(0) scale(0.98);
}

.bg-cell:disabled {
  cursor: not-allowed;
  opacity: .75;
}

.bg-cell-face {
  position: relative;
  z-index: 2;
  pointer-events: none;
  text-shadow: 0 2px 4px rgba(0,0,0,0.8);
  background: rgba(0,0,0,0.4);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
  border: 2px solid rgba(255,255,255,0.3);
  font-size: 18px;
}

/* Overlay nhẹ để chữ nổi trên ảnh */
.bg-cell::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.05) 100%);
  border-radius: 16px;
  pointer-events: none;
  z-index: 1;
}

/* Loading */
.bg-loading {
  position: absolute;
  /* đúng: phủ trong game block */
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(102, 126, 234, 0.8);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  z-index: 5;
}

.bg-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: bg-spin 1s linear infinite;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

@keyframes bg-spin {
  to {
    transform: rotate(360deg);
  }
}

.bg-wrap.is-busy .bg-cell {
  pointer-events: none;
}

/* Popup */
/* Popup: luôn giữa màn hình */
/* Overlay modal KHÔNG tham gia layout của .bg-wrap */
.bg-popup{
  position: fixed;
  inset: 0;
  display:flex;
  align-items:flex-start;
  justify-content:center;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(2px);
  z-index: 10000;
  animation: bg-popup-fade-in 0.3s ease-out;
  padding-top: 3rem;
}

@keyframes bg-popup-fade-in {
  from {
    opacity: 0;
    backdrop-filter: blur(0px);
  }
  to {
    opacity: 1;
    backdrop-filter: blur(2px);
  }
}

.bg-popup-box{
  position: relative;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  padding: 30px;
  border-radius: 20px;
  max-width: 400px;
  width: calc(100% - 40px);
  text-align: center;
  box-shadow: 
    0 20px 40px rgba(0,0,0,0.2),
    0 8px 16px rgba(0,0,0,0.1),
    inset 0 1px 0 rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.2);
  animation: bg-popup-box-slide-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: center;
}

/* Boom hint overlay - shows boom positions when popup is active */
.bg-boom-hint-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(1px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.bg-boom-hint-overlay.active {
  opacity: 1;
}

.bg-boom-hint-overlay .bg-cell {
  position: relative;
}

.bg-boom-hint-overlay .bg-cell.boom-hint::after {
  content: "💥";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 24px;
  z-index: 10001;
  animation: bg-boom-hint-pulse 1s ease-in-out infinite;
  text-shadow: 0 0 10px rgba(239, 68, 68, 0.8);
}

@keyframes bg-boom-hint-pulse {
  0%, 100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.7;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.2);
    opacity: 1;
  }
}

@keyframes bg-popup-box-slide-in {
  from {
    transform: scale(0.8) translateY(-20px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}
/* Fireworks full screen overlay */
.bg-fireworks {
  position: fixed;  /* thay vì absolute trong box */
  top: 0;
  left: 0;
  width: 100vw !important;
  height: 100vh !important;
  pointer-events: none;  /* không chặn click */
  z-index: 9999;         /* cao nhất */
}
.bg-popup-box .bg-victory-content{
  position:relative;
  z-index:1; /* để text/nút nằm trên canvas */
}
/* KHÔNG dùng khóa cuộn nếu không thật cần */
body.bg-lock {
  overflow: hidden;
}

/* .bg-wrap {
  position: relative;
} */

.bg-wrap .bg-grid {
  will-change: transform;
}

/* hint trình duyệt, tránh reflow kỳ quặc */
.bg-replay,
.bg-next {
  margin-top: 15px;
  padding: 12px 24px;
  border-radius: 12px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  border: 0;
  font-size: 16px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 
    0 4px 12px rgba(102, 126, 234, 0.3),
    0 2px 4px rgba(0,0,0,0.1);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.bg-replay:hover,
.bg-next:hover {
  transform: translateY(-2px);
  box-shadow: 
    0 8px 20px rgba(102, 126, 234, 0.4),
    0 4px 8px rgba(0,0,0,0.15);
}

.bg-replay {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  box-shadow: 
    0 4px 12px rgba(16, 185, 129, 0.3),
    0 2px 4px rgba(0,0,0,0.1);
}

.bg-replay:hover {
  box-shadow: 
    0 8px 20px rgba(16, 185, 129, 0.4),
    0 4px 8px rgba(0,0,0,0.15);
}

/* Overlay nhẹ để chữ nổi trên ảnh */
.bg-cell::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(0, 0, 0, .10);
  opacity: 0;
  transition: opacity .2s;
}

.bg-cell:hover::before {
  opacity: .06;
}

.bg-cell.revealed.boom::before {
  background: rgba(239, 68, 68, .18);
  opacity: 1;
}

.bg-replay,
.bg-next {
  margin-top: 10px;
  padding: 8px 14px;
  border-radius: 8px;
  background: #0ea5e9;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  border: 0;
}

.bg-replay {
  background: #e0f2fe;
  color: #0ea5e9;
  border: 2px solid #0ea5e9;
  font-weight: 700;
}

/* Nếu theme ghi đè, mở hai dòng dưới (chỉ khi cần) */
/* .bg-cell{ background-size:cover !important; background-position:center !important; } */
/* === WIN POPUP (PYRO STYLE) === */
@import url('https://fonts.googleapis.com/css2?family=Goblin+One&display=swap');

.bg-popup { background: transparent; } /* giữ nền trong suốt như yêu cầu */

/* Container khung win */
.bg-winbox {
  position: relative;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border-radius: 24px;
  width: min(400px, calc(100% - 40px));
  padding: 30px;
  box-shadow: 
    0 25px 50px rgba(0,0,0,0.25),
    0 10px 20px rgba(0,0,0,0.1),
    inset 0 1px 0 rgba(255,255,255,0.2);
  text-align: center;
  border: 1px solid rgba(255,255,255,0.2);
  backdrop-filter: blur(10px);
}

/* Vùng hiển thị pháo hoa */
.bg-winimage {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  height: 280px;
  border-radius: 20px;
  position: relative;
  overflow: hidden;
  box-shadow: 
    0 10px 30px rgba(102, 126, 234, 0.3),
    inset 0 1px 0 rgba(255,255,255,0.1);
}

/* Text "You Win!" */
.bg-wintext {
  position: absolute;
  top: 30px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 40px);
  color: #fff;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 28px;
  font-weight: 800;
  text-align: center;
  letter-spacing: 1px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
  animation: bg-pulse 2s infinite;
}
@keyframes bg-pulse {
  0% { transform: translateX(-50%) scale(.95); }
  70% { transform: translateX(-50%) scale(1.2); }
  100% { transform: translateX(-50%) scale(.95); }
}

/* Pyro container (2 lớp before/after) */
.bg-pyro > .before, .bg-pyro > .after {
  position: absolute;
  top: 50%; left: 50%;
  width: 6px; height: 6px;
  border-radius: 50%;
  /* box-shadow sẽ được JS gán động */
  animation:
    bg-bang 1s ease-out infinite backwards,
    bg-gravity 1.2s ease-in infinite backwards,
    bg-position 6s linear infinite backwards;
  transform: translate(-50%, -50%);
}
.bg-pyro > .after {
  animation-delay: .8s, .8s, .8s;
  animation-duration: 1.1s, 1.35s, 6.8s;
}

/* Nút */
.bg-win-actions {
  display: grid;
  grid-auto-flow: column;
  gap: 15px;
  margin-top: 20px;
}
.bg-win-btn {
  appearance: none;
  border: 0;
  padding: 14px 20px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.bg-win-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}
.bg-win-btn--primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}
.bg-win-btn--ghost {
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  color: #667eea;
  border: 2px solid #667eea;
}

/* Keyframes tương đương mixin trong SCSS mẫu */
@keyframes bg-bang {
  to {
    /* box-shadow được JS đặt ban đầu và khi chạy sẽ chuyển đổi trong quá trình animation */
    /* nội dung cụ thể do JS sinh, ở đây chỉ cần khai báo keyframe tồn tại */
  }
}
@keyframes bg-gravity {
  to {
    transform: translate(-50%, calc(-50% + 110px));
    opacity: 0;
  }
}
@keyframes bg-position {
  0%, 19.9%   { margin-top: 10%; margin-left: 40%; }
  20%, 39.9%  { margin-top: 40%; margin-left: 30%; }
  40%, 59.9%  { margin-top: 20%; margin-left: 70%; }
  60%, 79.9%  { margin-top: 30%; margin-left: 20%; }
  80%, 99.9%  { margin-top: 30%; margin-left: 80%; }
}
.pyro > .before, .pyro > .after {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  box-shadow: 0 0 #fff, 10px -50px hsl(200,100%,50%), -30px -80px hsl(340,100%,50%);
  animation: bang 1s ease-out infinite backwards,
             gravity 1s ease-in infinite backwards,
             position 5s linear infinite backwards;
}

.pyro > .after {
  animation-delay: 1.25s,1.25s,1.25s;
  animation-duration: 1.25s,1.25s,6.25s;
}

@keyframes bang {
  to {
    box-shadow: 100px -200px hsl(100,100%,50%),
                -120px -180px hsl(260,100%,50%),
                80px -150px hsl(20,100%,50%);
  }
}
@keyframes gravity {
  to {
    transform: translateY(200px);
    opacity: 0;
  }
}
@keyframes position {
  0%, 19.9% { margin-top: 10%; margin-left: 40%; }
  20%, 39.9% { margin-top: 40%; margin-left: 30%; }
  40%, 59.9% { margin-top: 20%; margin-left: 70%; }
  60%, 79.9% { margin-top: 30%; margin-left: 20%; }
  80%, 99.9% { margin-top: 30%; margin-left: 80%; }
}
/* Canvas hiệu ứng thua bằng Phaser */
/* Khung popup bao hiệu ứng */
.bg-winbox { position: relative; overflow: hidden; }

/* Canvas hiệu ứng thua phủ toàn bộ box */
.bg-lose-canvas{
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  /* Nếu box của bạn khá “phẳng”, thêm min-height để thấy rõ hiệu ứng */
  min-height: 260px;
}

/* Nội dung nằm trên hiệu ứng */
.bg-winimage, .bg-win-actions, .bg-id-form {
  position: relative;
  z-index: 1;
}
/* ===== Floating feed: random player + level ===== */
.bg-float-feed{
  position: fixed;
  bottom: 200px; /* Tăng khoảng cách lớn hơn để không che form */
  right: 20px;
  z-index: 9999;
  pointer-events: none; /* không chặn click game */
  max-width: 300px;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
}

.bg-float-item{
  position: relative;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  padding: 12px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 
    0 8px 32px rgba(102, 126, 234, 0.3),
    0 4px 16px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transform: translateX(100%) translateY(20px) scale(0.8);
  opacity: 0;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  
  /* Tối ưu hóa performance cho animations */
  will-change: transform, opacity;
  transform: translateZ(0) translateX(100%) translateY(20px) scale(0.8);
  backface-visibility: hidden;
  
  /* vào nhanh + bay lên mờ dần — thời lượng bay lấy từ CSS var --dur */
  animation:
    bg-float-in 500ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
    bg-float-up var(--dur, 3s) ease-in forwards;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.bg-float-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.05) 100%);
  border-radius: 20px;
  pointer-events: none;
}

.bg-float-item:hover {
  transform: translateZ(0) translateX(0) scale(1.05);
  box-shadow: 
    0 12px 40px rgba(102, 126, 234, 0.4),
    0 6px 20px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* Biến thể màu sắc cho các loại thông báo khác nhau */
.bg-float-item[data-type="level-up"] {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.bg-float-item[data-type="achievement"] {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.bg-float-item[data-type="milestone"] {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.bg-float-item[data-type="special"] {
  background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

/* Hiệu ứng pulse cho các thông báo đặc biệt */
.bg-float-item[data-type="special"]::after {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
  border-radius: 22px;
  z-index: -1;
  animation: bg-pulse-ring 2s infinite;
}

@keyframes bg-pulse-ring {
  0% {
    transform: scale(1);
    opacity: 0.7;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.3;
  }
  100% {
    transform: scale(1.1);
    opacity: 0;
  }
}

@keyframes bg-float-in { 
  to { 
    transform: translateZ(0) translateX(0) translateY(0) scale(1); 
    opacity: 1; 
  } 
}

@keyframes bg-float-up { 
  to { 
    transform: translateZ(0) translateX(0) translateY(-120px) scale(0.8); 
    opacity: 0; 
  } 
}

/* Responsive Design Improvements */
@media (max-width: 1024px) {
  .bg-wrap {
    margin: 15px;
    padding: 15px;
  }
  
  .bg-title {
    font-size: 20px;
  }
  
  .bg-grid {
    gap: 8px;
    padding: 8px;
  }
  
  .bg-cell {
    font-size: 32px;
  }
}

@media (max-width: 767px){
  .bg-wrap {
    margin: 10px;
    padding: 15px;
    border-radius: 16px;
  }
  
  .bg-title {
    font-size: 18px;
    margin-bottom: 15px;
  }
  
  .bg-grid {
    gap: 6px;
    padding: 6px;
    border-radius: 12px;
  }
  
  .bg-cell {
    font-size: 28px;
    border-radius: 12px;
  }
  
  .bg-popup-box {
    padding: 20px;
    border-radius: 16px;
    max-width: 320px;
  }
  
  .bg-winbox {
    padding: 20px;
    border-radius: 20px;
    max-width: 320px;
  }
  
  .bg-winimage {
    height: 200px;
    border-radius: 16px;
  }
  
  .bg-wintext {
    font-size: 22px;
    top: 20px;
  }
  
  .bg-float-feed{ 
    position: fixed; 
    bottom: 150px; /* Tăng khoảng cách lớn hơn cho mobile */
    right: 10px; 
    z-index: 9999; 
    pointer-events: none; 
    max-width: 250px;
  }
  .bg-float-item{ 
    font-size: 12px; 
    padding: 10px 14px;
    border-radius: 16px;
  }
  
  .bg-replay,
  .bg-next {
    padding: 10px 20px;
    font-size: 14px;
  }
  
  .bg-win-btn {
    padding: 12px 16px;
    font-size: 14px;
  }
}
/* Modern Leaderboard */
.bg-leaderboard-modern {
  margin-top: 25px;
  padding: 20px;
  background: linear-gradient(135deg, rgba(255,255,255,0.9) 0%, rgba(248,250,252,0.9) 100%);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 16px;
  backdrop-filter: blur(10px);
  box-shadow: 
    0 8px 20px rgba(0,0,0,0.1),
    inset 0 1px 0 rgba(255,255,255,0.2);
}

.bg-leaderboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 2px solid rgba(102, 126, 234, 0.1);
}

.bg-leaderboard-header h3 {
  margin: 0;
  color: #1f2937;
  font-size: 20px;
  font-weight: 700;
}

.bg-leaderboard-filters select {
  padding: 8px 12px;
  border: 2px solid rgba(102, 126, 234, 0.2);
  border-radius: 8px;
  background: white;
  font-size: 14px;
  color: #374151;
  cursor: pointer;
  transition: border-color 0.3s ease;
}

.bg-leaderboard-filters select:focus {
  outline: none;
  border-color: #667eea;
}

.bg-leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bg-leaderboard-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: all 0.3s ease;
  border: 2px solid transparent;
}

.bg-leaderboard-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.bg-leaderboard-item.bg-top-1 {
  background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
  border-color: #fbbf24;
}

.bg-leaderboard-item.bg-top-2 {
  background: linear-gradient(135deg, #e5e7eb 0%, #f3f4f6 100%);
  border-color: #9ca3af;
}

.bg-leaderboard-item.bg-top-3 {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  border-color: #d97706;
}

.bg-rank {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(102, 126, 234, 0.1);
  font-weight: 700;
  color: #667eea;
}

.bg-leaderboard-item.bg-top-1 .bg-rank {
  background: rgba(255, 215, 0, 0.2);
  color: #b45309;
}

.bg-leaderboard-item.bg-top-2 .bg-rank {
  background: rgba(156, 163, 175, 0.2);
  color: #374151;
}

.bg-leaderboard-item.bg-top-3 .bg-rank {
  background: rgba(245, 158, 11, 0.2);
  color: #92400e;
}

.bg-medal {
  font-size: 24px;
}

.bg-rank-number {
  font-size: 16px;
}

.bg-player-info {
  flex: 1;
}

.bg-player-name {
  font-weight: 600;
  color: #1f2937;
  font-size: 16px;
  margin-bottom: 4px;
}

.bg-player-stats {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: #6b7280;
}

.bg-player-stats span {
  background: rgba(102, 126, 234, 0.1);
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 500;
}

.bg-player-score {
  text-align: center;
  min-width: 60px;
}

.bg-score-value {
  font-size: 24px;
  font-weight: 700;
  color: #667eea;
  line-height: 1;
}

.bg-leaderboard-item.bg-top-1 .bg-score-value {
  color: #b45309;
}

.bg-leaderboard-item.bg-top-2 .bg-score-value {
  color: #374151;
}

.bg-leaderboard-item.bg-top-3 .bg-score-value {
  color: #92400e;
}

.bg-score-label {
  font-size: 10px;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* Legacy Leaderboard (for backward compatibility) */
.bg-leaderboard {
  margin-top: 25px;
  padding: 20px;
  background: linear-gradient(135deg, rgba(255,255,255,0.9) 0%, rgba(248,250,252,0.9) 100%);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 16px;
  backdrop-filter: blur(10px);
  box-shadow: 
    0 8px 20px rgba(0,0,0,0.1),
    inset 0 1px 0 rgba(255,255,255,0.2);
}

.bg-leaderboard-title {
  margin: 0 0 16px;
  font-size: 20px;
  font-weight: 700;
  color: #1f2937;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.bg-leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.bg-leaderboard-table th,
.bg-leaderboard-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid rgba(229,231,235,0.5);
}

.bg-leaderboard-table th {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.bg-leaderboard-table tr:nth-child(odd) td {
  background: rgba(255,255,255,0.8);
}
.bg-leaderboard-table tr:nth-child(even) td {
  background: rgba(248,250,252,0.8);
}

.bg-leaderboard-table tr:hover td {
  background: rgba(102,126,234,0.1);
  transform: translateX(2px);
  transition: all 0.2s ease;
}

/* Form message styles */
.bg-id-msg {
  font-size: 13px;
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  text-align: center;
  transition: all 0.3s ease;
  background: rgba(255,255,255,0.9);
  border: 1px solid rgba(255,255,255,0.2);
  backdrop-filter: blur(5px);
}

.bg-id-msg--error {
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  color: #dc2626;
  border: 1px solid #fecaca;
  box-shadow: 0 2px 4px rgba(220,38,38,0.1);
}

.bg-id-msg--success {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  color: #16a34a;
  border: 1px solid #bbf7d0;
  box-shadow: 0 2px 4px rgba(22,163,74,0.1);
}

.bg-id-msg--info {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  color: #2563eb;
  border: 1px solid #bfdbfe;
  box-shadow: 0 2px 4px rgba(37,99,235,0.1);
}

/* Form input styles */
.bg-id-name,
.bg-id-phone,
.bg-id-email {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 12px;
  font-size: 14px;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(5px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.bg-id-name:focus,
.bg-id-phone:focus,
.bg-id-email:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 
    0 0 0 3px rgba(102,126,234,0.1),
    0 4px 8px rgba(0,0,0,0.15);
  transform: translateY(-1px);
}


.bg-submit-identity {
  width: 100%;
  padding: 14px 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 
    0 4px 12px rgba(102, 126, 234, 0.3),
    0 2px 4px rgba(0,0,0,0.1);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.bg-submit-identity:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 
    0 8px 20px rgba(102, 126, 234, 0.4),
    0 4px 8px rgba(0,0,0,0.15);
}

.bg-submit-identity:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}
.bg-game-instructions {
  margin-top: 25px;
}