/* --- PHẦN CHUNG --- */
body {
  margin: 0;
  overflow: hidden;

}

/* BACKGROUND & OVERLAY - Giống 100% Test DEVO */
.background {
  position: fixed;
  inset: 0;
  background: url("https://images.unsplash.com/photo-1522383225653-ed111181a951") center/cover no-repeat;
  filter: brightness(0.7);
  z-index: 0;
  display: none; /* Chỉ hiện khi vào màn hình tổng kết */
}

.background.show {
  display: block;
}

#overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0);
  backdrop-filter: blur(0px);
  transition: 0.8s ease;
  z-index: 50;
}

#overlay.show {
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
}

/* SCREEN - ÉP HIỂN THỊ CHÍNH XÁC */
#summaryScreen, #leaderboardScreen {
  position: fixed;
  inset: 0;
  display: none !important; /* Mặc định ẩn để không đè menu */
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transform: translateY(40px) scale(0.95);
  transition: opacity 0.6s ease, transform 0.6s ease, visibility 0.6s;
  background: none !important; 
}

/* Khi có class show thì ép hiển thị */
#summaryScreen.show, #leaderboardScreen.show {
  display: flex !important;
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateY(0) scale(1) !important;
}

/* BOARD CONTAINER */
.board-container {
  width: 700px;
  max-height: 85vh;
  padding: 35px 40px;
  border-radius: 25px;
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(18px);
  box-shadow: 0 10px 50px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  color: white
}

.board-container .title {
  text-align: center;
  font-size: 32px;
  font-weight: 900;
  text-shadow: 0 0 15px rgba(255,255,255,0.4);
  margin-bottom: 10px;
  letter-spacing: 1px;
  color: white;
  font-family: "Segoe UI", sans-serif;
}

/* ROWS CONTAINER - Mask mờ 2 đầu */
.rows-container {
  flex: 1;
  overflow-y: auto;
  padding: 25px 15px; 
  margin: 0 -15px; 
  -ms-overflow-style: none; 
  scrollbar-width: none;    
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 10%, black 90%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0%, black 10%, black 90%, transparent 100%);
}

.rows-container::-webkit-scrollbar { display: none; }

/* ROW - Layout chuẩn 3 cột */
/* Tìm đoạn .row hiện tại và đảm bảo có transition */
.row {
  display: grid;
  grid-template-columns: 100px 1fr 100px; 
  align-items: center;
  padding: 16px;
  margin: 8px 0;
  border-radius: 14px;
  background: rgba(255,255,255,0.15);
  cursor: pointer;
  opacity: 0;
  transform: translateX(-20px);
  color: white;
  /* 👇 THÊM HOẶC SỬA DÒNG NÀY ĐỂ MƯỢT MÀ 👇 */
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), background 0.3s, opacity 0.4s, box-shadow 0.3s;
}

/* White text for regular rows (not top 3) */
.row:not(.gold):not(.silver):not(.bronze) {
  color: white;
}

/* 👇 THÊM ĐOẠN MỚI NÀY VÀO DƯỚI LỚP .row 👇 */
.row:hover {
  transform: scale(1.05); /* Phóng to thanh lên 5% */
  background: rgba(255, 255, 255, 0.3); /* Làm nền sáng hơn */
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4); /* Tạo bóng đổ cho thanh nổi lên */
  z-index: 10; /* Đảm bảo thanh đang hover nằm trên các thanh khác */
}

/* Hiệu ứng riêng biệt hơn cho thanh TỔNG ĐIỂM khi di chuột */
.total-row:hover {
  transform: scale(1.07); /* Thanh tổng điểm phóng to hơn chút nữa */
  background: rgba(0, 255, 204, 1) !important; /* Giữ màu xanh đặc trưng */
}
.row.show { opacity: 1; transform: translateX(0); }

/* THỨ HẠNG & MÀU SẮC */
.gold { background: linear-gradient(90deg, #ffd700, #ff8c00); color: #000; font-weight: bold; }
.silver { background: linear-gradient(90deg, #c0c0c0, #e0e0e0); color: #000; font-weight: bold; }
.bronze { background: linear-gradient(90deg, #cd7f32, #e6a15c); color: #000; font-weight: bold; }
.total-row { background: rgba(0, 255, 204, 0.8); color: #000; font-weight: 900; }
.you { border: 2px solid #00ffcc; }

/* SUMMARY EXTRA & BUTTONS */
.summary-extra {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 10px 0 20px 0;
  padding: 15px 20px;
  background: rgba(0,0,0,0.3);
  border-radius: 15px;
}
.badge-glow { color: #00ffcc; font-weight: bold; }

#summaryScreen button, 
#leaderboardScreen button {
  margin-top: 10px;
  padding: 16px;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: 0.3s;
}
.btn-primary { background: linear-gradient(45deg, #00ffcc, #00b3ff); color: #000; }
.btn-secondary { background: rgba(255,255,255,0.2); color: white; }
/* --- HIỆU ỨNG CÁNH HOA (PETAL) --- */
.petal {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  animation: fall 1.5s linear forwards;
  font-family: serif;
}

@keyframes fall {
  0% { opacity: 1; transform: translateY(0) rotate(0deg) scale(1); }
  100% { opacity: 0; transform: translateY(150px) rotate(180deg) scale(0.6); }
}

/* --- MODAL THÔNG TIN NGƯỜI CHƠI --- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: 0.4s ease;
  z-index: 999;
}

.modal.show { opacity: 1; pointer-events: auto; }

.profile-card {
  width: 320px;
  padding: 35px 30px;
  border-radius: 25px;
  background: rgba(20,20,35,0.98); 
  box-shadow: 0 15px 35px rgba(0,0,0,0.5);
  text-align: center;
  transform: translateY(20px);
  transition: 0.4s ease;
  color: white;
}

.profile-card h2 {
  color: white !important;
}

.modal.show .profile-card { transform: translateY(0); }

.rank-badge {
  display: inline-block;
  background: #ffcc00; 
  color: black;
  padding: 6px 18px;
  border-radius: 20px;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 20px;
}

.info-line { line-height: 2.2; font-size: 18px; color: white !important; }

/* Giữ nguyên phần .background, .screen, .row đã gửi ở các lượt trước */

/* Tự động bật ảnh nền khi màn hình kết thúc xuất hiện */
body:has(#summaryScreen.show, #leaderboardScreen.show) .background {
  display: block;
}