/* =====================================================================
   MENU CHÍNH — chữ nút, nút khóa, icon Thư viện, tiêu đề ảnh, nền động.
   Mọi màu / cỡ chữ lấy từ CONFIG.MENU_CHINH (js/menunen.js gán vào biến --mc-*). Số ở đây chỉ là giá trị dự phòng.
   ===================================================================== */

/* ---- 1. Chữ trên nút: mọi tên nút cùng một màu, mọi dòng phụ cùng một màu ---- */
#title .tbtns button,
#title .tbtns button.gold,
#title .tbtns button.tmodeBtn {
  color: var(--mc-chu, #FFF4DC) !important;
  text-shadow: 0 1px 0 #1a0f08, 1px 0 0 #1a0f08, -1px 0 0 #1a0f08, 0 -1px 0 #1a0f08 !important; /* viền chữ tối 1px: chữ không chìm vào vân gỗ */
  font-size: var(--mc-co, 18px);
}
#title .tbtns button.tbig { font-size: var(--mc-colon, 20px); }
/* MỌI nút trong menu cùng một kiểu bố cục: tên nút ở trên, dòng phụ ở dưới, khoảng cách dòng rõ ràng.
   (Lỗi cũ: khung bao ngoài có line-height 0, nút "Chơi tiếp" kế thừa nên dòng phụ co về cao 0 và chữ đè lên tên nút.) */
#title .tbtns button {
  line-height: 1.25 !important; height: auto !important; min-height: 52px;
  display: flex !important; flex-direction: column !important; align-items: center; justify-content: center; gap: 2px;
  padding: 6px 10px !important; white-space: normal; text-align: center; overflow-wrap: anywhere;
}
#title .tbtns button.tbig, #title .tbtns button.tmodeBtn { min-height: 60px; } /* nút có dòng phụ: cùng chiều cao */
#title .tbtns button { font-weight: 700; } #title .tbtns button small { font-weight: 400; } /* mọi tên nút cùng độ đậm (trước: chỉ nút gợi ý in đậm) */
#title .tbtns button small {
  position: static !important; display: block !important; transform: none !important; margin: 0 !important;
  line-height: 1.25 !important; height: auto !important; white-space: normal !important; max-width: 100%;
}
#title .tbtns button small,
.tmenu .tbtns button.tmodeBtn small {
  color: var(--mc-phu, #EBD9B4) !important;
  font-size: var(--mc-cophu, 14px) !important;
  opacity: 1 !important;
  text-shadow: 0 1px 0 #1a0f08, 1px 0 0 #1a0f08, -1px 0 0 #1a0f08 !important;
}
/* nút đang được gợi ý (Chiến dịch / Chơi tiếp): chữ vẫn trắng kem, nổi bật bằng viền vàng sáng */
#title .tbtns button.gold { box-shadow: 0 0 0 2px var(--mc-vien, #F0C76A), 0 0 10px rgba(240,199,106,.45) !important; }

/* ---- Nút còn khóa (Vô tận): nhạt hơn, nền tối thêm, có ổ khóa; vẫn đọc rõ (>= 3:1) ---- */
#title .tbtns button.tmodeBtn.locked {
  filter: none !important; opacity: 1 !important; cursor: help;
  position: relative; isolation: isolate;
  color: var(--mc-khoa-chu, #D9CBB0) !important;
}
#title .tbtns button.tmodeBtn.locked::before { /* lớp tối phủ lên nền gỗ, nằm DƯỚI chữ */
  content: ""; position: absolute; inset: 3px; z-index: -1; pointer-events: none;
  background: rgba(16,10,6,var(--mc-khoa-toi, .5));
}
#title .tbtns button.tmodeBtn.locked small { color: var(--mc-khoa-phu, #D9CBB0) !important; font-style: italic; }

/* ---- 2. Icon Thư viện: ảnh PixelLab đơn sắc dùng làm mặt nạ, tô đúng màu chữ (currentColor) ---- */
#title .mcIcon {
  display: inline-block; width: var(--mc-icon, 16px); height: var(--mc-icon, 16px); margin-right: 6px; vertical-align: -2px;
  background-color: currentColor;
  -webkit-mask: var(--mc-icon-url) center / contain no-repeat; mask: var(--mc-icon-url) center / contain no-repeat;
  image-rendering: pixelated;
}
#title #btnThuVien { flex-direction: row !important; gap: 0; }

/* ---- 4. Tiêu đề ảnh PixelLab (309x167 phần có hình trong ảnh 396x168), cỡ 1x, không xuống dòng lẻ ---- */
#title .tlogo.mcLogo {
  width: 309px; max-width: 100%; aspect-ratio: 309 / 167; height: auto; margin: 0 auto;
  background: var(--mc-logo-url) no-repeat; background-size: calc(100% * 396 / 309) auto; background-position: 54% 0; /* cắt lề trong suốt: 47px trái, 40px phải (47 / (47 + 40) = 54%) */
  image-rendering: pixelated; color: transparent; font-size: 0; text-shadow: none; letter-spacing: 0;
  border: 0; box-shadow: none; padding: 0;
  filter: drop-shadow(0 3px 0 rgba(0,0,0,.45));
}
#title .tlogo.mcLogo::before, #title .tlogo.mcLogo::after { display: none !important; }
#title .tsub { color: var(--mc-phu, #EBD9B4) !important; text-shadow: 0 1px 0 #1a0f08, 1px 0 0 #1a0f08, -1px 0 0 #1a0f08; font-size: 14px !important; letter-spacing: 1px !important; line-height: 1.5 !important; white-space: nowrap; text-align: center; }
#title .tsub::before, #title .tsub::after { margin: 0 6px !important; color: var(--mc-vien, #F0C76A) !important; }

/* ---- 3. Nền động: canvas phủ màn hình, dưới khung menu ---- */
#title canvas.mcNen { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 0; image-rendering: pixelated; border: 0; display: block; aspect-ratio: auto; pointer-events: none; }
#title.mcCoNen canvas.tart { display: none !important; }
#title.mcCoNen .tshade { background: radial-gradient(ellipse at 50% 50%, rgba(14,9,5,var(--mc-toi-giua, .15)) 0, rgba(14,9,5,calc((var(--mc-toi-giua, .15) + var(--mc-toi-ria, .75)) / 2)) 62%, rgba(14,9,5,var(--mc-toi-ria, .75)) 100%) !important; }
#title.mcCoNen .tmenu { background: rgba(30,20,12,.86); }

/* điện thoại: lề nhỏ hơn để tiêu đề giữ cỡ 1x */
@media (max-width: 420px) {
  body.ui2 #title { padding: 8px; }
  #title .tmenu { padding: 16px 10px; }
}
/* màn hình hơi thấp (481–780px): tiêu đề đúng 1/2, khoảng cách gọn lại để cả menu (kể cả nút "Chơi tiếp") nằm trong màn hình */
@media (max-height: 780px) and (min-height: 481px) {
  #title .tlogo.mcLogo { width: 155px; }
  #title .tmenu { gap: 8px; padding-top: 14px; padding-bottom: 14px; }
  #title .tbtns { gap: 8px; }
  body.ui2 #title { padding-top: 8px; padding-bottom: 8px; }
}
/* điện thoại ngang / màn hình thấp: 2 cột (tiêu đề + dòng phụ + kỷ lục bên trái, các nút bên phải) để cả khung menu nằm gọn trong màn hình */
@media (max-height: 480px) and (min-width: 560px) {
  body.ui2 #title { padding: 8px; }
  #title .tmenu { width: min(780px, 100%); display: grid; grid-template-columns: 309px 1fr; grid-template-rows: auto auto 1fr; column-gap: 14px; row-gap: 4px; padding: 10px 12px; align-items: center; }
  #title .tmenu > .tlogo { grid-column: 1; grid-row: 1; width: 309px; } /* tiêu đề giữ đúng 1x */
  #title .tmenu > .tsub { grid-column: 1; grid-row: 2; white-space: nowrap; margin: 0; letter-spacing: 0 !important; }
  #title .tmenu > .tsub::before, #title .tmenu > .tsub::after { margin: 0 4px !important; }
  #title .tmenu > .tbest { grid-column: 1; grid-row: 3; text-align: center; align-self: start; }
  #title .tmenu > .tbtns { grid-column: 2; grid-row: 1 / span 3; display: grid !important; grid-template-columns: 1fr 1fr; gap: 6px; }
  #title .tbtns button, #title .tbtns button.tbig, #title .tbtns button.tmodeBtn { min-height: 46px !important; padding: 4px 6px !important; font-size: 16px !important; flex-direction: column !important; }
  #title .tbtns button small { font-size: var(--mc-cophu, 14px) !important; line-height: 1.15; }
  #title .tmenu > .tpanel { grid-column: 1 / span 2; }
}
@media (max-height: 480px) and (min-width: 560px) and (max-width: 719px) { /* màn ngang hẹp: tiêu đề đúng 1/2 */
  #title .tmenu { grid-template-columns: 155px 1fr; }
  #title .tmenu > .tlogo { width: 155px; }
  #title .tmenu > .tsub { white-space: normal; }
}
@media (max-height: 480px) and (max-width: 559px) { #title .tlogo.mcLogo { width: 155px; } }
