html,
body {
  max-width: 100%;
  overflow-x: hidden;
}
#main,
#fullscr,
#puzzle-container,
#forPuzzle {
  max-width: 100%;
  /* chặn tuyệt đối tràn ngang */
  -webkit-box-sizing: border-box;
          box-sizing: border-box;
}
body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}
:root {
  --puzzle-bg: #F5FAE1;
  --vh: 1vh;
  /* fallback */
}
#main {
  min-height: 100vh;
  width: 100%;
}
#main #section-top {
  position: relative;
  padding: 5px 15px;
}
#main #section-top #menu {
  margin: 0;
  padding: 0;
  list-style-type: none;
  position: absolute;
  top: 5px;
  right: 15px;
  z-index: 1000;
  display: inline-block;
  text-align: center;
}
#main #section-top #menu li {
  margin-bottom: 1px;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  background-color: #c82254;
  color: #fff;
}
#main #section-top #menu li:first-child {
  padding-top: 0;
}
#main #section-top #menu li:hover {
  background-color: #FAA619;
}
#main #puzzle-container {
  position: relative;
  width: 100vw;
  max-width: 100%;
  height: 80vh;
}
#main #puzzle-container #forPuzzle {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  background-color: #F5FAE1;
  background-image: url("assets/images/classic_bg.jpg");
  background-repeat: repeat;
  background-position: bottom center;
  background-size: contain;
  overflow: hidden;
}
#main #puzzle-container #forPuzzle:before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  background-color: var(--puzzle-bg);
  opacity: 0.6;
}
#main #panel {
  background-image: -webkit-gradient(linear, left top, left bottom, from(#363636), to(#121212));
  background-image: linear-gradient(to bottom, #363636, #121212);
  color: #fff;
}
#main #panel svg {
  color: #fff;
}
#main #panel .btn-dropup {
  color: #fff;
}
#main #panel .btn-dropup::after {
  display: none !important;
}
#main #panel .btn {
  color: #fff;
}
.polypiece {
  display: block;
  overflow: hidden;
  position: absolute;
}
.moving {
  -webkit-transition-property: top, left;
  transition-property: top, left;
  -webkit-transition-duration: 1s;
          transition-duration: 1s;
  -webkit-transition-timing-function: linear;
          transition-timing-function: linear;
}
.gameCanvas {
  display: none;
  overflow: hidden;
  position: absolute;
}
header a {
  outline-offset: unset !important;
  text-decoration: none !important;
}
header a:focus,
header a:active {
  outline: none !important;
}
.create-link {
  background-color: #c82254 !important;
  color: #fff !important;
  border-radius: 3px !important;
}
.create-link a {
  outline-offset: unset !important;
  text-decoration: none !important;
}
.create-link a:focus,
.create-link a:active {
  outline: none !important;
}
@media screen and (min-width: 768px) {
  .create-link {
    padding: 2px 10px !important;
  }
}
#previewOverlay {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 30%;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  z-index: 3000;
  -webkit-box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
          box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  /* thêm bóng đổ */
  overflow: hidden;
  /* tránh ảnh bên trong bị tràn */
}
#previewOverlay img {
  -o-object-fit: fill;
     object-fit: fill;
  cursor: -webkit-zoom-in;
  cursor: zoom-in;
}
/* Ảnh phóng to toàn màn hình */
.zoom-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  z-index: 3001;
  opacity: 0;
  -webkit-animation: fadeIn 0.25s forwards;
          animation: fadeIn 0.25s forwards;
  cursor: -webkit-zoom-out;
  cursor: zoom-out;
  /* thêm dòng này */
}
.zoom-overlay img {
  max-width: 90%;
  max-height: 90%;
  border-radius: 0.5rem;
  -webkit-box-shadow: 0 0 25px rgba(0, 0, 0, 0.5);
          box-shadow: 0 0 25px rgba(0, 0, 0, 0.5);
  -webkit-transform: scale(0.95);
          transform: scale(0.95);
  -webkit-animation: zoomIn 0.25s forwards;
          animation: zoomIn 0.25s forwards;
  cursor: inherit !important;
  /* kế thừa từ overlay => ổn định */
}
.btn-close-white {
  -webkit-filter: brightness(0) invert(1);
          filter: brightness(0) invert(1);
  opacity: 1 !important;
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  padding: 0.6rem;
}
.btn-close-white:hover {
  background-color: rgba(255, 255, 255, 0.4);
}
@-webkit-keyframes fadeIn {
  to {
    opacity: 1;
  }
}
@keyframes fadeIn {
  to {
    opacity: 1;
  }
}
@-webkit-keyframes zoomIn {
  to {
    -webkit-transform: scale(1);
            transform: scale(1);
  }
}
@keyframes zoomIn {
  to {
    -webkit-transform: scale(1);
            transform: scale(1);
  }
}
.zoom-overlay.fade-out {
  -webkit-animation: fadeOut 0.25s forwards;
          animation: fadeOut 0.25s forwards;
}
@-webkit-keyframes fadeOut {
  to {
    opacity: 0;
  }
}
@keyframes fadeOut {
  to {
    opacity: 0;
  }
}
.popover.wide-popover {
  max-width: 600px !important;
  width: 500px;
  height: 400px;
  overflow: hidden;
  overflow-x: hidden;
  overflow-y: scroll;
}
.bxh table.table-top-3 {
  max-width: 100%;
}
.bxh table.table-top-3 td {
  padding: 0.25rem;
}
.bxh .progress {
  background-color: #c82254;
  color: #fff;
}
@media screen and (max-width: 767px) {
  .wp-block-site-logo img {
    width: 130px;
    height: 29px;
  }
  #main #puzzle-container {
    height: calc(var(--vh, 1vh) * 70);
    /* mobile mặc định */
  }
  #previewOverlay {
    width: 80%;
  }
  .popover.wide-popover {
    width: 400px;
    height: 350px;
  }
}
@media screen and (max-width: 575px) {
  .popover.wide-popover {
    width: 100%;
    height: 350px;
  }
}
.grid-container {
  margin: 0;
  padding: 0;
  display: -ms-grid;
  display: grid;
  grid-gap: 20px;
  grid-auto-rows: 1fr;
  -ms-grid-columns: 1fr 20px 1fr;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-flow: dense;
  counter-reset: albumList;
}
.grid-container .item {
  aspect-ratio: 1;
  background: #ccc;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;
  position: relative;
  /* Number */
  /*&:before {
      counter-increment: albumList;
      content: counter(albumList);
      margin: auto;
      font-size: 40px;
      color: #000000;
    }*/
}
.grid-container .item a {
  text-decoration: none;
}
.grid-container .item .item-img {
  width: 100%;
  height: 100%;
  -o-object-fit: cover;
     object-fit: cover;
  opacity: 0.9;
}
.grid-container .item .item-img:hover {
  opacity: 1;
}
.grid-container .item .item-meta {
  position: absolute;
  bottom: 10px;
  left: 10px;
  right: 10px;
  overflow: hidden;
  color: #fff;
  z-index: 1;
}
.grid-container .item .admin-tool {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  /*overflow: hidden;*/
  color: #fff;
  z-index: 1;
}
.grid-container .item .admin-tool .dropdown-menu {
  /*position: absolute !important;
        z-index: 9999 !important;*/
}
.grid-container .item .item-title {
  white-space: nowrap;
  /* chỉ 1 dòng */
  overflow: hidden;
  /* ẩn phần thừa */
  text-overflow: ellipsis;
  /* thêm dấu ... */
  max-width: 150px;
  /* giới hạn chiều rộng */
}
/* màn nhỏ hơn 575px */
@media screen and (max-width: 35.9375em) {
  .grid-container {
    -ms-grid-columns: 1fr;
    grid-template-columns: 1fr;
    grid-auto-rows: unset;
  }
  .grid-container .item {
    aspect-ratio: unset;
  }
  .grid-container .item .item-title {
    max-width: 250px;
  }
}
/* <=767px */
/*@media screen and (max-width: 767px) {
  .grid-container {
    grid-gap: 10px;
    .item{
      .item-title{
        max-width: 110px;
      }
      .admin-tool{
        left: 5px;
        right: 5px;
      }
     .item-meta{
      left: 5px;
      right: 5px;
      img{
        width: 24px;
      }
     }
    }
  }
}*/
@media screen and (min-width: 40em) and (max-width: 63.99875em) {
  /* 640 ~ 1023 */
  .grid-container {
    -ms-grid-columns: 1fr 20px 1fr 20px 1fr;
    grid-template-columns: repeat(3, 1fr);
  }
  .grid-container .item:nth-child(6n + 1),
  .grid-container .item:nth-child(6n + 6) {
    grid-area: span 2 / span 2;
  }
  .grid-container .item:nth-child(6n + 5) {
    -ms-grid-column: 1;
    grid-column: 1;
  }
}
@media print, screen and (min-width: 64em) {
  /* 1024+ */
  .grid-container {
    -ms-grid-columns: 1fr 20px 1fr 20px 1fr 20px 1fr;
    grid-template-columns: repeat(4, 1fr);
  }
  .grid-container .item:nth-child(10n + 1),
  .grid-container .item:nth-child(10n + 10) {
    grid-area: span 2 / span 2;
  }
  .grid-container .item:nth-child(10n + 8) {
    -ms-grid-column: 1;
    grid-column: 1;
  }
  .grid-container .item:nth-child(10n + 9) {
    -ms-grid-column: 2;
    grid-column: 2;
  }
}
.page-link {
  color: #c82254 !important;
}
.active > .page-link,
.page-link.active {
  border-color: #c82254 !important;
  background-color: #c82254 !important;
  color: #fff !important;
}
.btn-brand {
  --bs-btn-color: #fff !important;
  --bs-btn-bg: #c82254 !important;
  --bs-btn-border-color: #c82254 !important;
  --bs-btn-hover-color: #fff !important;
  --bs-btn-hover-bg: #de3f6f;
  --bs-btn-hover-border-color: #de3f6f;
  --bs-btn-focus-shadow-rgb: 225, 83, 97;
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: #9c1b42;
  --bs-btn-active-border-color: #9c1b42;
  --bs-btn-active-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
  --bs-btn-disabled-color: #fff;
  --bs-btn-disabled-bg: #c82254;
  --bs-btn-disabled-border-color: #c82254;
}
ul.recent-puzzles {
  margin: 0;
  padding: 0;
  list-style: none;
}
ul.recent-puzzles li {
  border-bottom: #ccc solid 1px;
}
ul.recent-puzzles li a {
  display: block;
  padding: 10px 0;
  text-decoration: none;
  color: var(--bs-body-color);
}
ul.recent-puzzles li a span:first-letter {
  text-transform: uppercase;
}
ul.recent-puzzles li a img {
  width: 30px;
  border: var(--bs-gray-400) solid 2px;
  margin-right: 5px;
}
ul.recent-puzzles li a:hover {
  background-color: #eee;
  color: #c82254;
}
.btn-remove-recent-puzzles {
  background-color: #eee !important;
  color: #0693e3;
  border: none;
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
}
.btn-remove-recent-puzzles:hover {
  background-color: #c82254 !important;
  color: #fff !important;
}
.puzzle-categories {
  display: none;
  grid-gap: 20px;
  /*grid-auto-rows: 1fr;*/
  -ms-grid-columns: 1fr 20px 1fr 20px 1fr 20px 1fr;
  grid-template-columns: repeat(4, 1fr);
  font-size: 1rem;
  background-color: var(--wp--preset--color--accent-5);
  padding: 15px;
  list-style: none;
  margin: 0;
}
.puzzle-categories.show {
  display: -ms-grid;
  display: grid;
}
.puzzle-categories li a {
  text-decoration: none;
  color: var(--bs-body-color);
}
.puzzle-categories li a:hover {
  color: #c82254;
}
.puzzle-categories li.active {
  font-weight: bold;
}
@media screen and (max-width: 1024px) {
  .puzzle-categories {
    -ms-grid-columns: 1fr 20px 1fr 20px 1fr;
    grid-template-columns: repeat(3, 1fr);
  }
}
@media screen and (max-width: 768px) {
  .puzzle-categories {
    -ms-grid-columns: 1fr 15px 1fr;
    grid-template-columns: repeat(2, 1fr);
    grid-gap: 15px;
  }
  .puzzle-categories:not(.show) {
    display: none;
  }
}
@media screen and (max-width: 575px) {
  .puzzle-categories {
    -ms-grid-columns: 1fr;
    grid-template-columns: repeat(1, 1fr);
  }
}
#ghost-image {
  position: absolute;
  top: 50%;
  left: 50%;
  -webkit-transform: translate(-50%, -50%);
          transform: translate(-50%, -50%);
  opacity: 0.3;
  pointer-events: none;
  /* không cản trở thao tác kéo thả mảnh */
  z-index: 1;
  /* dưới timer và menu, nhưng trên nền */
  display: none;
}
.modal-body-scroll {
  max-height: 400px;
  /* quan trọng. Nếu lớn sẽ không scoll được và không phân trang ở mục quản lý links */
  overflow-y: auto;
}
.btn-fav {
  background: transparent;
  cursor: pointer;
  padding: 5px;
}
.btn-fav.active svg {
  color: #c82254;
  fill: #c82254;
}
body.dark-mode .bxh .progress {
  background-color: #c82254;
}
body.dark-mode .popover {
  background-color: #121212 !important;
}
body.dark-mode .btn-remove-recent-puzzles {
  background-color: #6C757D !important;
}
body.dark-mode .btn-remove-recent-puzzles:hover {
  background-color: #de3f6f !important;
  color: #fff !important;
}
body.dark-mode .list-group {
  background-color: #1e1e1e;
  border-color: #333;
}
body.dark-mode .list-group .list-group-item {
  background-color: #2a2a2a;
  color: #f0f0f0;
  border-color: #444;
}
body.dark-mode .list-group .list-group-item:hover {
  background-color: #3a3a3a;
  color: #fff;
}
body.dark-mode .list-group .list-group-item.active {
  background-color: #0d6efd;
  border-color: #0d6efd;
  color: #fff;
}
body.dark-mode .pagination .page-link {
  background-color: #2a2a2a;
  border-color: #444;
  color: #ddd;
}
body.dark-mode .pagination .page-link:hover {
  background-color: #3a3a3a;
  color: #fff;
  border-color: #555;
}
body.dark-mode .pagination .page-item.disabled .page-link {
  background-color: #1e1e1e;
  border-color: #333;
  color: #666;
}
body.dark-mode .puzzle-categories {
  background-color: #2a2a2a;
  color: #eee;
}
body.dark-mode .puzzle-categories li a {
  color: #eee;
}
body.dark-mode .puzzle-categories li a:hover {
  color: #c82254;
}
body.dark-mode ul.recent-puzzles li a {
  color: #eee;
}
body.dark-mode ul.recent-puzzles li a:hover {
  background-color: #2a2a2a;
  color: #c82254;
}
