/* =====================================================================
   Trang chủ QuizRacer 2D - Views/Home/Index.cshtml và Views/Home/Join.cshtml
   Tiền tố: qh- (home). Cần nạp sau qr-site.css.
   ===================================================================== */

/* ---------- Khu vực giới thiệu (hero) ---------- */
.qh-hero { position: relative; overflow: hidden; padding: 2.4rem 0 0; text-align: center; }
.qh-hero .container { position: relative; z-index: 2; }

.qh-deco { position: absolute; border: 3px solid var(--qs-ink); z-index: 1; pointer-events: none; }
.qh-deco-sun { width: 118px; height: 118px; border-radius: 50%; background: var(--qs-butter); top: -22px; left: -26px; animation: qh-float 7s ease-in-out infinite; }
.qh-deco-sq { width: 64px; height: 64px; border-radius: 18px; background: var(--qs-mint); top: 92px; right: 7%; transform: rotate(12deg); animation: qh-float 6s ease-in-out -2s infinite; }
.qh-deco-circ { width: 96px; height: 96px; border-radius: 50%; background: var(--qs-pink); top: 250px; right: -30px; animation: qh-float 8s ease-in-out -1s infinite; }
.qh-deco-tri { width: 50px; height: 50px; border-radius: 14px; background: var(--qs-sky); top: 210px; left: 6%; transform: rotate(-14deg); animation: qh-float 6.5s ease-in-out -3s infinite; }

.qh-cloud { position: absolute; z-index: 1; width: 104px; height: auto; image-rendering: pixelated; opacity: .95; pointer-events: none; animation: qh-drift linear infinite; }
.qh-cloud.c1 { top: 38px; left: 0; animation-duration: 70s; animation-delay: -20s; }
.qh-cloud.c2 { top: 118px; left: 0; width: 78px; animation-duration: 95s; animation-delay: -60s; }
.qh-cloud.c3 { top: 190px; left: 0; width: 90px; animation-duration: 82s; animation-delay: -35s; }

.qh-star {
  display: inline-flex; align-items: center; justify-content: center;
  width: 78px; height: 78px; background: var(--qs-butter);
  border: 3px solid var(--qs-ink); border-radius: 20px; box-shadow: 4px 4px 0 var(--qs-ink);
  transform: rotate(-4deg); animation: qh-wiggle 4s ease-in-out infinite;
}
.qh-star img { width: 46px; height: auto; image-rendering: pixelated; }

.qh-title {
  font-family: var(--qs-font-head); font-weight: 800; letter-spacing: -1px; line-height: 1;
  font-size: clamp(3.1rem, 10.5vw, 5.8rem); margin: 1.1rem 0 .7rem;
  text-shadow: 4px 4px 0 var(--qs-pink);
}
.qh-pill {
  display: inline-block; background: var(--qs-ink); color: #fff; font-weight: 800;
  border-radius: 999px; padding: .38rem 1.2rem; font-size: 1.02rem;
}
.qh-lead { max-width: 46rem; margin: 1.1rem auto 0; font-weight: 700; font-size: 1.12rem; line-height: 1.6; }

/* Đường đua pixel */
.qh-road {
  position: relative; height: 92px; margin-top: 1.8rem;
  background: #cdd3f0; border-top: var(--qs-border); border-bottom: var(--qs-border); overflow: hidden;
}
.qh-road::before {
  content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 4px; margin-top: -2px;
  background: linear-gradient(90deg, #fff 50%, transparent 50%) 0 0 / 56px 4px repeat-x;
  animation: qh-road 1s linear infinite;
}
.qh-car { position: absolute; left: 0; width: 80px; height: auto; image-rendering: pixelated; will-change: transform; }
.qh-car.c1 { top: 5px; animation: qh-drive 12s linear infinite; animation-delay: -3s; }
.qh-car.c2 { bottom: 5px; animation: qh-drive 8.5s linear infinite; animation-delay: -6s; }
.qh-car.c3 { top: 5px; animation: qh-drive 16s linear infinite; animation-delay: -11s; }
.qh-car.c4 { bottom: 5px; animation: qh-drive 14s linear infinite; animation-delay: -1s; }

/* ---------- Hai thẻ chính ---------- */
.qh-cards { margin-top: 2.4rem; }
.qh-card {
  position: relative; height: 100%; display: flex; flex-direction: column;
  border: var(--qs-border); border-radius: 24px; box-shadow: 8px 8px 0 var(--qs-ink);
  padding: 1.4rem 1.5rem 1.5rem;
  transition: transform .15s ease, box-shadow .15s ease;
}
.qh-card:hover { transform: translate(-2px, -2px); box-shadow: 10px 10px 0 var(--qs-ink); }
.qh-card-player { background: var(--qs-coral); }
.qh-card-creator { background: var(--qs-mint); }

.qh-card-head { display: flex; align-items: center; gap: .9rem; margin-bottom: 1.1rem; }
.qh-card-icon {
  flex: 0 0 58px; width: 58px; height: 58px; display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .75); border: 3px solid var(--qs-ink); border-radius: 16px;
}
.qh-card-icon img { width: 38px; height: auto; image-rendering: pixelated; }
.qh-card-title { font-family: var(--qs-font-head); font-weight: 800; font-size: 1.6rem; line-height: 1.05; margin: 0; }
.qh-card-title small { display: block; font-family: var(--qs-font); font-weight: 700; font-size: .92rem; opacity: .8; margin-top: 2px; }

/* Ô nhập mã */
.qh-join { background: var(--qs-white); border: var(--qs-border); border-radius: 18px; padding: 1rem 1rem 1.05rem; margin-bottom: 1rem; }
.qh-join label { font-weight: 800; display: block; margin-bottom: .4rem; }
.qh-code-wrap { position: relative; }
.qh-code-input {
  width: 100%; min-height: 50px; padding: .4rem 4.2rem .4rem 1rem;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-weight: 800; font-size: 1.3rem;
  letter-spacing: .24em; text-transform: uppercase; color: var(--qs-ink);
  background: var(--qs-cream); border: var(--qs-border); border-radius: 14px;
}
.qh-code-input::placeholder { letter-spacing: .24em; color: #b7b0d0; }
.qh-code-input:focus { outline: 3px solid #6c5ce7; outline-offset: 2px; background: #fff; }
.qh-code-input.is-bad { border-color: #d6314f; background: #fff1f3; }
.qh-code-input.is-ok { border-color: #1b9a6b; }
.qh-code-count { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-weight: 800; font-size: .85rem; color: #6d668f; pointer-events: none; }
.qh-join-msg:empty { display: none; }
.qh-join-msg { margin: .45rem 0 0; font-weight: 700; font-size: .88rem; color: #c02544; }
.qh-join-hint { margin: .35rem 0 0; font-size: .8rem; font-weight: 700; color: #6d668f; }
.qh-join-actions { display: flex; gap: .6rem; margin-top: .7rem; flex-wrap: wrap; }
.qh-join-actions .qs-btn { flex: 1 1 165px; }

/* Các ô chức năng của người chơi: 1 ô lớn + 3 ô nhỏ cùng hàng */
.qh-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; margin-top: auto; }
.qh-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2rem;
  min-height: 78px; padding: .55rem .5rem; text-align: center; line-height: 1.15;
  background: var(--qs-white); color: var(--qs-ink); font-weight: 800; font-size: .92rem; text-decoration: none;
  border: var(--qs-border); border-radius: 16px; box-shadow: 3px 3px 0 var(--qs-ink);
  transition: transform .1s ease, box-shadow .1s ease;
}
.qh-tile:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--qs-ink); color: var(--qs-ink); }
.qh-tile:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--qs-ink); }
.qh-tile:focus-visible { outline: 3px solid #6c5ce7; outline-offset: 3px; }
.qh-tile .ico { font-size: 1.45rem; line-height: 1; }
.qh-tile small { display: block; font-weight: 700; font-size: .72rem; opacity: .75; }
.qh-tile-main {
  grid-column: 1 / -1; flex-direction: row; justify-content: flex-start; gap: .8rem; min-height: 64px; text-align: left; padding: .55rem 1rem;
  background: var(--qs-ink); color: #fff; font-size: 1.05rem;
}
.qh-tile-main:hover { color: #fff; background: #2d2858; }
.qh-tile-main .go { margin-left: auto; font-size: 1.2rem; }

/* Danh sách chức năng của người sáng tạo */
.qh-rows { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .6rem; }
.qh-row {
  display: flex; align-items: center; gap: .7rem; min-height: 50px; padding: .5rem .8rem;
  background: var(--qs-white); color: var(--qs-ink); font-weight: 800; text-decoration: none;
  border: var(--qs-border); border-radius: 14px; box-shadow: 3px 3px 0 var(--qs-ink);
  transition: transform .1s ease, box-shadow .1s ease;
}
a.qh-row:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--qs-ink); color: var(--qs-ink); }
a.qh-row:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--qs-ink); }
a.qh-row:focus-visible { outline: 3px solid #6c5ce7; outline-offset: 3px; }
.qh-row .ico { font-size: 1.25rem; line-height: 1; }
.qh-row.is-locked { opacity: .6; box-shadow: none; border-style: dashed; cursor: not-allowed; }
.qh-chip {
  margin-left: auto; font-size: .7rem; font-weight: 800; white-space: nowrap;
  border: 2px solid var(--qs-ink); border-radius: 999px; padding: 1px 9px; background: var(--qs-white);
}
.qh-chip.is-ready { background: #8be6bf; }
.qh-chip.is-partial { background: var(--qs-butter); }
.qh-chip.is-soon { background: var(--qs-lav); }
.qh-chip.is-lock { background: #e7e4f3; }

.qh-cta { margin-top: auto; display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.qh-note { flex: 1 1 100%; margin: 0; font-size: .85rem; font-weight: 700; background: rgba(255, 255, 255, .7); border: 2px dashed var(--qs-ink); border-radius: 12px; padding: .5rem .75rem; }

/* ---------- Dải Bảng xếp hạng ---------- */
.qh-banner {
  display: flex; align-items: center; gap: 1rem; margin-top: 2.2rem; padding: 1rem 1.3rem;
  background: var(--qs-lav); color: var(--qs-ink); text-decoration: none;
  border: var(--qs-border); border-radius: 22px; box-shadow: 8px 8px 0 var(--qs-ink);
  transition: transform .15s ease, box-shadow .15s ease;
}
.qh-banner:hover { transform: translate(-2px, -2px); box-shadow: 10px 10px 0 var(--qs-ink); color: var(--qs-ink); }
.qh-banner:focus-visible { outline: 3px solid #6c5ce7; outline-offset: 4px; }
.qh-banner-icon { flex: 0 0 54px; width: 54px; height: 54px; display: flex; align-items: center; justify-content: center; background: rgba(255, 255, 255, .8); border: var(--qs-border); border-radius: 16px; }
.qh-banner-icon img { width: 34px; image-rendering: pixelated; }
.qh-banner-title { display: block; font-family: var(--qs-font-head); font-weight: 800; font-size: 1.4rem; line-height: 1.1; }
.qh-banner-sub { display: block; font-weight: 700; font-size: .92rem; opacity: .85; }
.qh-banner .qs-btn { margin-left: auto; }

/* ---------- Các mục phía dưới ---------- */
.qh-section { padding-top: 3.4rem; scroll-margin-top: 90px; }
.qh-h2 { font-family: var(--qs-font-head); font-weight: 800; font-size: clamp(1.8rem, 4.5vw, 2.4rem); line-height: 1.1; margin: 0 0 .4rem; }
.qh-h2 span { background: linear-gradient(transparent 58%, var(--qs-butter) 58%); padding: 0 .15em; }
.qh-sub { font-weight: 700; color: #4f4a72; margin-bottom: 1.4rem; max-width: 42rem; }

/* Bảng xếp hạng nổi bật */
.qh-lb { list-style: none; margin: 0; padding: 0; display: grid; gap: .65rem; }
.qh-lb-item { display: flex; align-items: center; gap: .85rem; padding: .6rem .9rem; background: var(--qs-white); border: var(--qs-border); border-radius: 16px; box-shadow: 3px 3px 0 var(--qs-ink); }
.qh-lb-item.is-me { background: var(--qs-butter); }
.qh-rank { flex: 0 0 42px; width: 42px; height: 42px; display: flex; align-items: center; justify-content: center; font-family: var(--qs-font-head); font-weight: 800; font-size: 1.15rem; background: var(--qs-lav); border: var(--qs-border); border-radius: 12px; }
.qh-lb-item:nth-child(1) .qh-rank { background: #ffd84d; }
.qh-lb-item:nth-child(2) .qh-rank { background: #dfe3f2; }
.qh-lb-item:nth-child(3) .qh-rank { background: #ffc79a; }
.qh-lb-name { font-weight: 800; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qh-lb-name small { font-weight: 700; color: #6d668f; }
.qh-score { margin-left: auto; font-family: var(--qs-font-head); font-weight: 800; font-size: 1.3rem; white-space: nowrap; }
.qh-score small { font-family: var(--qs-font); font-size: .72rem; font-weight: 800; color: #6d668f; }
.qh-empty { text-align: center; padding: 1.6rem 1rem; background: var(--qs-white); border: 3px dashed var(--qs-ink); border-radius: 18px; font-weight: 700; }
.qh-empty img { width: 52px; image-rendering: pixelated; display: block; margin: 0 auto .5rem; }

.qh-callout { height: 100%; background: var(--qs-sky); border: var(--qs-border); border-radius: 22px; box-shadow: 6px 6px 0 var(--qs-ink); padding: 1.4rem; text-align: center; display: flex; flex-direction: column; align-items: center; gap: .6rem; justify-content: center; }
.qh-callout img { width: 84px; image-rendering: pixelated; animation: qh-float 5s ease-in-out infinite; }
.qh-callout h3 { font-family: var(--qs-font-head); font-weight: 800; font-size: 1.5rem; margin: 0; }
.qh-callout p { margin: 0; font-weight: 700; }

/* Hướng dẫn sử dụng */
.qh-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.3rem; }
.qh-step { position: relative; padding: 1.6rem 1.1rem 1.1rem; background: var(--qs-white); border: var(--qs-border); border-radius: 20px; box-shadow: 5px 5px 0 var(--qs-ink); }
.qh-step-no { position: absolute; top: -17px; left: 14px; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; font-family: var(--qs-font-head); font-weight: 800; border: var(--qs-border); border-radius: 50%; background: var(--qs-pink); }
.qh-step:nth-child(2) .qh-step-no { background: var(--qs-mint); }
.qh-step:nth-child(3) .qh-step-no { background: var(--qs-sky); }
.qh-step:nth-child(4) .qh-step-no { background: var(--qs-orange); }
.qh-step img { width: 44px; height: auto; image-rendering: pixelated; margin-bottom: .5rem; }
.qh-step h3 { font-family: var(--qs-font-head); font-weight: 800; font-size: 1.2rem; margin: 0 0 .3rem; }
.qh-step p { margin: 0; font-weight: 600; font-size: .94rem; line-height: 1.5; }
.qh-kbd { display: inline-block; min-width: 30px; padding: 0 7px; text-align: center; font-weight: 800; font-size: .85rem; background: #fff; border: 2px solid var(--qs-ink); border-bottom-width: 4px; border-radius: 8px; }
.qh-rules { margin-top: 1.4rem; display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }
.qh-rule { padding: .75rem .9rem; background: rgba(255, 255, 255, .7); border: 2px dashed var(--qs-ink); border-radius: 14px; font-weight: 700; font-size: .9rem; }
.qh-rule b { display: block; font-family: var(--qs-font-head); font-size: 1.02rem; }

/* Giới thiệu hệ thống */
.qh-stats { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.qh-stat { padding: .9rem; text-align: center; border: var(--qs-border); border-radius: 18px; box-shadow: 4px 4px 0 var(--qs-ink); }
.qh-stat b { display: block; font-family: var(--qs-font-head); font-weight: 800; font-size: 2rem; line-height: 1.1; }
.qh-stat span { font-weight: 800; font-size: .85rem; }
.qh-stat:nth-child(1) { background: var(--qs-pink); }
.qh-stat:nth-child(2) { background: var(--qs-mint); }
.qh-stat:nth-child(3) { background: var(--qs-sky); }
.qh-stat:nth-child(4) { background: var(--qs-orange); }
.qh-about-text p { font-weight: 600; line-height: 1.65; }
.qh-roles { margin-top: 1.6rem; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.qh-role { padding: 1rem 1.1rem; background: var(--qs-white); border: var(--qs-border); border-radius: 18px; box-shadow: 4px 4px 0 var(--qs-ink); }
.qh-role h3 { font-family: var(--qs-font-head); font-weight: 800; font-size: 1.15rem; margin: 0 0 .3rem; }
.qh-role p { margin: 0; font-weight: 600; font-size: .92rem; line-height: 1.5; }

/* Trang Join (tạm) */
.qh-join-page { max-width: 560px; margin: 3rem auto 0; padding: 0 1rem; }
.qh-join-card { background: var(--qs-white); border: var(--qs-border); border-radius: 24px; box-shadow: 8px 8px 0 var(--qs-ink); padding: 1.8rem; text-align: center; }
.qh-join-card img { width: 64px; image-rendering: pixelated; margin-bottom: .6rem; }
.qh-join-card h1 { font-family: var(--qs-font-head); font-weight: 800; font-size: 1.8rem; }
.qh-code-show { display: inline-block; font-family: ui-monospace, Consolas, monospace; font-weight: 800; font-size: 1.6rem; letter-spacing: .25em; background: var(--qs-butter); border: var(--qs-border); border-radius: 14px; padding: .3rem 1rem; margin: .4rem 0 1rem; }

/* Cửa sổ quét QR */
.qh-modal .modal-content { border: var(--qs-border); border-radius: 22px; box-shadow: 8px 8px 0 var(--qs-ink); overflow: hidden; }
.qh-modal .modal-header { border-bottom: 3px solid var(--qs-ink); background: var(--qs-butter); }
.qh-modal .modal-title { font-family: var(--qs-font-head); font-weight: 800; }
.qh-scan-box { position: relative; background: var(--qs-ink); border: var(--qs-border); border-radius: 16px; overflow: hidden; aspect-ratio: 4 / 3; }
.qh-scan-box video { width: 100%; height: 100%; object-fit: cover; display: block; }
.qh-scan-box::after { content: ""; position: absolute; inset: 18%; border: 3px dashed rgba(255, 255, 255, .85); border-radius: 18px; pointer-events: none; }
.qh-scan-msg { margin: .8rem 0 0; font-weight: 700; text-align: center; }

/* ---------- Hiệu ứng ---------- */
@keyframes qh-float { 0%, 100% { transform: translateY(0) rotate(var(--r, 0deg)); } 50% { transform: translateY(-10px) rotate(var(--r, 0deg)); } }
@keyframes qh-wiggle { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg) translateY(-3px); } }
@keyframes qh-drift { from { transform: translateX(-140px); } to { transform: translateX(calc(100vw + 140px)); } }
@keyframes qh-drive { from { transform: translateX(-110px); } to { transform: translateX(calc(100vw + 30px)); } }
@keyframes qh-road { to { background-position: -56px 0; } }
.qh-deco-sq { --r: 12deg; }
.qh-deco-tri { --r: -14deg; }

.qh-hidden { opacity: 0; transform: translateY(20px); }
.qh-hidden.is-visible { opacity: 1; transform: none; transition: opacity .55s ease, transform .55s ease; }

@media (prefers-reduced-motion: reduce) {
  .qh-hero *, .qh-callout img, .qh-card, .qh-banner { animation: none !important; transition: none !important; }
  .qh-hidden { opacity: 1; transform: none; }
  .qh-car.c1 { transform: translateX(8vw); } .qh-car.c2 { transform: translateX(38vw); }
  .qh-car.c3 { transform: translateX(62vw); } .qh-car.c4 { transform: translateX(84vw); }
}

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
  .qh-steps { grid-template-columns: repeat(2, 1fr); }
  .qh-roles, .qh-rules { grid-template-columns: 1fr; }
  .qh-card { box-shadow: 6px 6px 0 var(--qs-ink); }
}
@media (max-width: 359.98px) {
  .qh-tiles { grid-template-columns: 1fr; }
}
@media (max-width: 575.98px) {
  .qh-hero { padding-top: 1.6rem; }
  .qh-deco-sq, .qh-deco-tri, .qh-deco-circ { display: none; }
  .qh-deco-sun { width: 84px; height: 84px; top: -18px; left: -22px; }
  .qh-lead { font-size: 1rem; padding: 0 .25rem; }
  .qh-road { height: 82px; }
  .qh-car { width: 68px; }
  .qh-card { padding: 1.1rem 1rem 1.2rem; border-radius: 20px; }
  .qh-card-title { font-size: 1.35rem; }
  .qh-code-input { font-size: 1.15rem; letter-spacing: .18em; }
  .qh-steps { grid-template-columns: 1fr; gap: 1.6rem; }
  .qh-banner { flex-wrap: wrap; padding: .9rem 1rem; }
  .qh-banner .qs-btn { margin-left: 0; width: 100%; }
  .qh-chip { font-size: .66rem; padding: 1px 7px; }
  .qh-row { padding: .5rem .65rem; }
  .qh-stats { grid-template-columns: 1fr 1fr; }
}
