/* public/css/home.css — trang chủ (banner, thao tác nhanh, Game Hot, thanh điều hướng dưới). */
.home-v2 {
  --h-blue: #2f7cf6;
  --h-green: #22b45a;
  --h-purple: #8a4df0;
  --h-orange: #ff8a1f;
}

/* ---- Đầu trang ---- */
.home-v2 .home-header {
  gap: 8px;
  padding: 8px 16px;
}
.ltk-logo {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
}
.ltk-logo .crown {
  width: 34px;
  height: 22px;
  margin-bottom: 4px;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25));
}
.ltk-text {
  font-size: 30px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: 0.5px;
  line-height: 1;
  background: linear-gradient(180deg, #ffe680 0%, #ffb400 55%, #e07800 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-stroke: 1px #9a4c00;
  filter: drop-shadow(0 2px 0 rgba(120, 50, 0, 0.35));
}
.home-v2 .user-menu {
  gap: 8px;
}
.home-v2 .user-menu > .btn,
.home-v2 .user-menu > button:not(.theme-switch) {
  border-radius: 999px;
  padding: 7px 16px;
  font-weight: 600;
}
.home-v2 .user-menu > a.btn:not(.reg-btn)::before {
  content: '';
  width: 16px;
  height: 16px;
  margin-right: 6px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='8' r='4.2'/%3E%3Cpath d='M3.5 21c.6-4.4 4-7 8.5-7s7.9 2.6 8.5 7z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='8' r='4.2'/%3E%3Cpath d='M3.5 21c.6-4.4 4-7 8.5-7s7.9 2.6 8.5 7z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.home-v2 .user-menu > .reg-btn {
  background: var(--h-blue);
  border-color: var(--h-blue);
  color: #fff;
}

/* Công tắc sáng / tối */
.theme-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 64px;
  height: 32px;
  padding: 0 !important;
  border-radius: 999px;
  border: 1px solid var(--border, #d6dbe4);
  background: var(--card-2);
  font-size: 15px;
  overflow: hidden;
}
.theme-switch span {
  position: relative;
  z-index: 1;
  flex: 1;
  text-align: center;
  line-height: 30px;
  transition: color 0.2s;
}
.theme-switch::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 29px;
  height: 26px;
  border-radius: 999px;
  background: #ffc53d;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s, background 0.2s;
}
.theme-switch .ts-sun {
  color: #8a4b00;
}
.theme-switch .ts-moon {
  color: var(--muted);
}
.theme-switch.dark::before {
  transform: translateX(31px);
  background: #3b4a78;
}
.theme-switch.dark .ts-sun {
  color: var(--muted);
}
.theme-switch.dark .ts-moon {
  color: #ffe08a;
}

/* ---- Khung nội dung ---- */
.home2 {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 16px 24px;
}
.home2 > .card,
.home2 > .grid-2 {
  margin-top: 18px;
}

/* ---- Banner ---- */
.hero2 {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  min-height: 170px;
  aspect-ratio: 8 / 3;
  max-height: 300px;
  display: flex;
  align-items: center;
  box-shadow: 0 6px 18px rgba(143, 20, 17, 0.25);
}
.hero2-deco {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.hero2-text {
  position: relative;
  padding: 0 5%;
  max-width: 64%;
  text-align: center;
}
.hero2-l1,
.hero2-l2 {
  font-weight: 900;
  font-style: italic;
  line-height: 1.05;
  color: #fff6c9;
  text-shadow: 0 3px 0 #9c2a07, 0 0 3px #9c2a07, 0 5px 10px rgba(0, 0, 0, 0.35);
}
.hero2-l2 {
  text-shadow: none;
  filter: drop-shadow(0 3px 0 #9c2a07) drop-shadow(0 4px 6px rgba(0, 0, 0, 0.35));
}
.hero2-l1 {
  font-size: clamp(20px, 5.4vw, 44px);
}
.hero2-l2 {
  font-size: clamp(30px, 8.6vw, 72px);
  background: linear-gradient(180deg, #fff7c2 0%, #ffd23f 55%, #ff9d00 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero2-ribbon {
  display: inline-block;
  margin-top: 8px;
  padding: 5px 14px;
  border-radius: 6px;
  background: linear-gradient(180deg, #d8261b, #a3120c);
  border: 1.5px solid #ffcf4a;
  color: #fff3c4;
  font-weight: 800;
  font-size: clamp(10px, 2.6vw, 16px);
  letter-spacing: 0.3px;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* ---- Thao tác nhanh ---- */
.quick4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 14px 0 6px;
}
.q-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 4px 10px;
  border-radius: 14px;
  border: 1px solid var(--border, #e3e7ee);
  background: var(--card);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 2px 6px rgba(20, 30, 60, 0.06);
}
.q-item:hover {
  transform: translateY(-1px);
}
.q-ic {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 12px;
}
.q-ic svg {
  width: 26px;
  height: 26px;
}
.q-ic.blue {
  background: linear-gradient(160deg, #57a0ff, var(--h-blue));
}
.q-ic.green {
  background: linear-gradient(160deg, #4cd37e, var(--h-green));
}
.q-ic.purple {
  background: linear-gradient(160deg, #ad7bff, var(--h-purple));
}
.q-ic.orange {
  background: linear-gradient(160deg, #ffad55, var(--h-orange));
}

/* ---- Game Hot ---- */
.sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 0 10px;
  scroll-margin-top: 64px;
}
.sec-head h2 {
  margin: 0;
  font-size: 20px;
}
.see-all {
  color: var(--h-blue);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
}
.hot-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}
.hot-tile {
  grid-column: span 2;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  min-height: 0;
  min-width: 0;
  padding: 0;
  border-radius: 14px;
  overflow: hidden;
  border: 2px solid transparent;
  background: var(--tile, #2f7cf6);
  color: #fff;
  text-align: center;
  box-shadow: 0 3px 8px rgba(20, 30, 60, 0.15);
  transition: transform 0.12s, box-shadow 0.12s;
}
.hot-tile.wide {
  grid-column: span 3;
}
.hot-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(20, 30, 60, 0.22);
}
.hot-tile.active {
  border-color: #ffc53d;
  box-shadow: 0 0 0 2px #ffc53d, 0 6px 14px rgba(20, 30, 60, 0.22);
}
.hot-art {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
}
.hot-tile.wide .hot-art {
  aspect-ratio: 16 / 7;
}
.hot-art svg {
  display: block;
  width: 100%;
  height: 100%;
}
.hot-art .art-icon {
  display: grid;
  place-items: center;
  height: 100%;
  font-size: 44px;
  background: radial-gradient(circle at 50% 45%, rgba(255, 255, 255, 0.35), transparent 70%);
}
.hot-art .check {
  position: absolute;
  top: 6px;
  right: 6px;
  display: none;
  width: 22px;
  height: 22px;
  line-height: 22px;
  border-radius: 50%;
  background: #ffc53d;
  color: #5a3500;
  font-weight: 800;
  font-size: 13px;
}
.hot-tile.active .check {
  display: block;
}
.hot-name {
  padding: 7px 4px 8px;
  font-weight: 800;
  font-size: 15px;
  background: var(--tile-dark, rgba(0, 0, 0, 0.25));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.hot-tile.soon .hot-art {
  filter: saturate(0.9);
}
.soon-badge {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  padding: 3px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.c-blue {
  --tile: #2f7cf6;
  --tile-dark: #1d5fcc;
}
.c-gold {
  --tile: #e0a21a;
  --tile-dark: #b97f05;
}
.c-red {
  --tile: #e0403a;
  --tile-dark: #b52520;
}
.c-green {
  --tile: #22a95a;
  --tile-dark: #168543;
}
.c-teal {
  --tile: #1f9bb5;
  --tile-dark: #137a90;
}
.c-pink {
  --tile: #d0457e;
  --tile-dark: #a72d60;
}
.c-purple {
  --tile: #8a4df0;
  --tile-dark: #6a30cf;
}
.c-orange {
  --tile: #ff8a1f;
  --tile-dark: #e06a00;
}

/* ---- Popup tạo phòng, bảng xếp hạng ---- */
body.modal-open {
  overflow: hidden;
}
.modal.sheet .box {
  max-width: 640px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0;
  padding: 20px 22px;
  animation: create-pop 0.16s ease-out;
}
@keyframes create-pop {
  from {
    transform: translateY(12px) scale(0.98);
    opacity: 0;
  }
}
.modal.sheet .create-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.modal.sheet .create-head > div {
  flex: 1;
  min-width: 0;
}
.modal.sheet .create-head p {
  margin: 0 0 12px;
}
#rankModal .box {
  max-width: 520px;
  min-height: min(480px, 70dvh);
}
#rankModal .leaderboard {
  margin: 0;
}
.create-close {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 50%;
  font-size: 16px;
  line-height: 1;
}
.create-games {
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 0 14px;
  padding-bottom: 2px;
}
.create-games::-webkit-scrollbar {
  display: none;
}
.create-games button {
  flex-shrink: 0;
  white-space: nowrap;
}
#createModal .create-foot .msg-error:empty {
  display: none;
}
/* Đã tạo phòng: chỉ còn mã mời + nút vào phòng */
#createModal .created #createGames,
#createModal .created #loginNeeded,
#createModal .created #optionsForm,
#createModal .created .create-foot {
  display: none !important;
}
#createModal .created .invite {
  margin-top: 4px;
}
#createModal .create-foot {
  position: sticky;
  bottom: -20px;
  margin: 8px -22px -20px;
  padding: 14px 22px 16px;
  background: var(--card);
}

/* ---- Hộp nhập mã ---- */
#joinModal .box {
  width: min(360px, calc(100vw - 32px));
}
#joinModal .code-input {
  width: 100%;
  font-size: 22px;
  letter-spacing: 4px;
  text-align: center;
  text-transform: uppercase;
}

/* ---- Màn hình rộng: banner trải hết khung, 4 game / hàng ---- */
@media (min-width: 761px) {
  .hero2 {
    aspect-ratio: auto;
    height: 280px;
  }
  .hero2-l1 {
    white-space: nowrap;
  }
  .hot-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
  }
  .hot-tile,
  .hot-tile.wide {
    grid-column: span 1;
  }
  .hot-tile.wide .hot-art {
    aspect-ratio: 16 / 10;
  }
}

/* ---- Thanh điều hướng dưới (chỉ điện thoại) ---- */
.bottom-nav {
  display: none;
}
@media (max-width: 760px) {
  .home-v2 .home-header {
    padding: 6px 12px;
  }
  .ltk-text {
    font-size: 26px;
  }
  .home-v2 .user-menu {
    gap: 6px;
  }
  .home-v2 .user-menu > .btn,
  .home-v2 .user-menu > button:not(.theme-switch) {
    padding: 6px 11px;
    font-size: 13px;
    min-height: 34px;
  }
  .home-v2 .user-menu .reg-btn {
    display: inline-flex;
  }
  .theme-switch {
    width: 56px;
    height: 30px;
    min-width: 0 !important;
    min-height: 0 !important;
  }
  .theme-switch::before {
    width: 25px;
    height: 24px;
  }
  .theme-switch.dark::before {
    transform: translateX(27px);
  }
  .theme-switch span {
    line-height: 28px;
  }
  .home2 {
    padding: 10px 12px 20px;
  }
  /* Điện thoại: popup trượt lên từ dưới */
  .modal.sheet {
    align-items: flex-end;
    padding: 0;
    z-index: 70;
  }
  .modal.sheet .box,
  #rankModal .box {
    max-width: none;
    max-height: 92dvh;
    border-radius: 18px 18px 0 0;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
    animation-name: create-sheet;
  }
  #createModal .create-foot {
    bottom: calc(-16px - env(safe-area-inset-bottom));
    margin: 8px -16px calc(-16px - env(safe-area-inset-bottom));
    padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  }
  @keyframes create-sheet {
    from {
      transform: translateY(40px);
      opacity: 0.4;
    }
  }
  .hero2 {
    border-radius: 14px;
    aspect-ratio: 16 / 8;
  }
  .hero2-text {
    max-width: 70%;
    padding: 0 3%;
  }
  .quick4 {
    gap: 8px;
  }
  .q-item {
    font-size: 13px;
    padding: 10px 2px 8px;
  }
  .q-ic {
    width: 42px;
    height: 42px;
  }
  .hot-grid {
    gap: 8px;
  }
  .hot-name {
    font-size: 14px;
  }
  .home-v2 .site-footer {
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
  }
  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: var(--card);
    border-top: 1px solid var(--border, #e3e7ee);
    box-shadow: 0 -2px 10px rgba(20, 30, 60, 0.08);
  }
  .bottom-nav a,
  .bottom-nav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 4px 0;
    border: 0;
    background: none;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
    min-height: 0;
  }
  .bottom-nav svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
  }
  .bottom-nav .active {
    color: var(--h-blue);
  }
}
@media (max-width: 380px) {
  .ltk-logo .crown {
    width: 28px;
  }
  .ltk-text {
    font-size: 22px;
  }
  .home-v2 .user-menu > .btn,
  .home-v2 .user-menu > button:not(.theme-switch) {
    padding: 6px 9px;
    font-size: 13px;
  }
  .home-v2 .user-menu > a.btn:not(.reg-btn)::before {
    display: none;
  }
  .home-v2 .user-menu .reg-btn {
    display: none;
  }
  .hot-name {
    font-size: 12.5px;
  }
  .q-item {
    font-size: 12px;
  }
  .bottom-nav a,
  .bottom-nav button {
    font-size: 10px;
    white-space: nowrap;
  }
}
