@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap');

/* ===== Design tokens ===== */
:root {
  --blue: #3B82F6; --blue-600: #2563EB; --blue-50: #EFF6FF; --blue-100: #DBEAFE;
  --pink: #F9A8D4; --pink-50: #FDF2F8; --pink-100: #FCE7F3;
  --ink: #0F172A; --muted: #64748B; --line: #E2E8F0; --surface: #F8FAFC; --white: #FFFFFF; --gray: #E2E8F0; --black: #0F172A;
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --pill: 999px;
  --sh-sm: 0 2px 8px rgba(15,23,42,.06);
  --sh-md: 0 6px 16px rgba(15,23,42,.10);
  --sh-blue: 0 4px 12px rgba(37,99,235,.25);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Nunito', system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--surface);
  color: var(--ink);
  line-height: 1.55;
  max-width: 760px;
  margin: 0 auto;
  padding: 18px clamp(16px, 4vw, 32px) 56px;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
img { display: block; }

/* ===== Thanh quay lại ===== */
.topbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 22px; }
.topbar a {
  display: inline-flex; align-items: center;
  background: var(--white); border: 1px solid var(--line); border-radius: var(--pill);
  padding: 8px 14px; font-size: 14px; font-weight: 700; color: var(--blue-600); box-shadow: var(--sh-sm);
  transition: transform .16s ease, box-shadow .16s ease;
}
.topbar a:hover { transform: translateY(-1px); box-shadow: var(--sh-md); }

.page-title { font-size: 24px; font-weight: 800; margin-bottom: 20px; }

/* ===== Trang chủ ===== */
body.home-page { display: flex; flex-direction: column; }
.home { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 88vh; gap: 6px; text-align: center; }
.logo { width: 120px; height: 120px; display: grid; place-items: center; margin-bottom: 4px; }
.logo img { width: 100%; height: 100%; object-fit: contain; }
.logo .logo-fallback {
  width: 110px; height: 110px; border-radius: 26px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--blue), var(--pink)); color: #fff; font-weight: 800; font-size: 22px; letter-spacing: 1px;
}
.brand-name { font-size: 30px; font-weight: 800; letter-spacing: 1px; }
.brand-tag { font-size: 14px; color: var(--muted); font-weight: 600; margin-bottom: 22px; }

.nav-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
.navc {
  background: var(--white); border-radius: var(--r-lg); box-shadow: var(--sh-sm);
  padding: 18px; display: flex; flex-direction: column; gap: 6px; text-align: left;
  transition: transform .16s ease, box-shadow .16s ease;
}
.navc:hover { transform: translateY(-2px); box-shadow: var(--sh-md); }
.navc:active { transform: scale(.98); }
.navc .ic { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; font-size: 23px; }
.navc .ic.b { background: var(--blue-50); }
.navc .ic.p { background: var(--pink-50); }
.navc .t { font-weight: 800; font-size: 16px; }
.navc .s { font-size: 12px; color: var(--muted); font-weight: 600; }

/* ===== Bảng giá ===== */
.cards { display: grid; grid-template-columns: 1fr; gap: 16px; }
.card { background: var(--white); border-radius: var(--r-lg); box-shadow: var(--sh-sm); overflow: hidden; transition: transform .16s ease, box-shadow .16s ease; }
.card:hover { transform: translateY(-2px); box-shadow: var(--sh-md); }
.card-image {
  height: 150px; position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--blue), #60A5FA);
  display: grid; place-items: center; color: rgba(255,255,255,.85); font-size: 13px; font-weight: 700; letter-spacing: 1px;
}
.card-image::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,.30), transparent 60%); }
.card-image img { width: 100%; height: 100%; object-fit: cover; position: relative; z-index: 1; }
.card-body { padding: 16px; }
.card-name { font-size: 18px; font-weight: 800; margin-bottom: 4px; }
.card-price { font-size: 22px; font-weight: 800; color: var(--blue-600); }
.card-price small { font-size: 14px; font-weight: 600; color: var(--muted); }
.card-note { margin-top: 12px; font-size: 15px; color: var(--muted); white-space: pre-wrap; }
.card .more {
  display: inline-block; margin-top: 14px; padding: 11px 20px; border-radius: var(--r-md);
  background: var(--blue); color: #fff; font-size: 15px; font-weight: 700; box-shadow: var(--sh-blue);
}
.card .more:active { transform: scale(.98); }

.placeholder-note { margin-top: 8px; color: var(--muted); font-size: 16px; }

/* ===== List game ===== */
body.list-page { max-width: 960px; margin: 0 auto; padding: 0; }

.list-header, .filter-bar {
  position: fixed; left: 50%; transform: translateX(-50%); width: 100%; max-width: 960px; background: var(--white); z-index: 10;
}
.list-header {
  top: 0; height: 58px; display: flex; align-items: center; gap: 12px; padding: 0 16px;
  border-radius: 0 0 var(--r-lg) var(--r-lg); box-shadow: var(--sh-sm);
}
.filter-bar { top: 58px; height: 54px; display: flex; align-items: center; gap: 10px; padding: 0 16px; }

.icon-btn {
  width: 42px; height: 42px; flex: 0 0 42px; border-radius: 12px; display: grid; place-items: center;
  background: var(--blue-50); color: var(--blue-600); overflow: hidden;
}
.icon-btn:active { transform: scale(.95); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }

.search-box {
  flex: 1; height: 42px; display: flex; align-items: center; gap: 8px; padding: 0 16px;
  border-radius: var(--pill); background: #F1F5F9; color: var(--muted); font: inherit; cursor: pointer;
}
.search-box svg { width: 18px; height: 18px; flex: 0 0 18px; }
.search-placeholder { color: #94A3B8; font-size: 15px; font-weight: 600; }

.filter-btn {
  display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 16px; border-radius: var(--pill);
  background: var(--white); border: 1px solid var(--line); color: var(--ink); font: inherit; font-size: 14px; font-weight: 700;
  box-shadow: var(--sh-sm); cursor: pointer; transition: transform .16s ease, box-shadow .16s ease;
}
.filter-btn:hover { transform: translateY(-1px); box-shadow: var(--sh-md); }
.filter-btn svg { width: 16px; height: 16px; color: var(--blue); }

.sort-wrap { position: relative; }
.sort-menu {
  position: absolute; top: calc(100% + 8px); left: 0; min-width: 190px;
  background: var(--white); border-radius: var(--r-md); box-shadow: var(--sh-md); border: 1px solid var(--line);
  display: none; z-index: 20; overflow: hidden;
}
.sort-menu.open { display: block; }
.sort-menu button {
  display: block; width: 100%; text-align: left; padding: 13px 16px; border: 0; border-bottom: 1px solid var(--line);
  background: var(--white); color: var(--ink); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
}
.sort-menu button:last-child { border-bottom: 0; }
.sort-menu button:hover { background: var(--blue-50); }
.sort-menu button.active { font-weight: 800; color: var(--blue-600); }
.sort-menu button.active::before { content: "✓ "; }

.list-content { padding-top: 124px; }
.section-title { display: flex; align-items: center; gap: 8px; padding: 12px 16px 8px; font-size: 18px; font-weight: 800; }
.section-title::before { content: ""; width: 5px; height: 20px; border-radius: var(--pill); background: var(--blue); flex: 0 0 5px; }

/* Kệ Collection */
.shelf { margin-bottom: 18px; }
.shelf-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 16px 8px; }
.shelf-head .h { font-size: 17px; font-weight: 800; }
.shelf-head a { font-size: 13px; font-weight: 700; color: var(--blue-600); }
.shelf-track { display: flex; gap: 12px; overflow-x: auto; padding: 4px 16px 8px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.shelf-track::-webkit-scrollbar { display: none; }
.shelf-card { flex: 0 0 128px; scroll-snap-align: start; }
.shelf-card .t { width: 128px; height: 128px; border-radius: var(--r-lg); background: linear-gradient(135deg, var(--blue-100), var(--pink-100)); overflow: hidden; box-shadow: var(--sh-sm); }
.shelf-card .t img { width: 100%; height: 100%; object-fit: cover; }
.shelf-card .n { font-size: 13px; font-weight: 700; margin-top: 6px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Chip filter */
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 16px 4px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: var(--pill); background: var(--blue-50); color: var(--blue-600); border: 1px solid var(--blue-100); font-size: 13px; font-weight: 700; }
.chip button { border: 0; background: none; cursor: pointer; font-size: 12px; opacity: .7; padding: 0; line-height: 1; color: inherit; }

/* Lưới game */
.game-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 0 16px 24px; }
.game-item { background: var(--white); border-radius: var(--r-md); box-shadow: var(--sh-sm); overflow: hidden; color: inherit; transition: transform .16s ease, box-shadow .16s ease; }
.game-item:hover { transform: translateY(-3px); box-shadow: var(--sh-md); }
.game-thumb { width: 100%; aspect-ratio: 1/1; background: linear-gradient(135deg, var(--blue-100), var(--pink-100)); overflow: hidden; }
.game-thumb img { width: 100%; height: 100%; object-fit: cover; }
.game-name {
  padding: 8px 10px 10px; font-size: 12.5px; font-weight: 700; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word;
  min-height: calc(12.5px * 1.3 * 2 + 18px);
}

/* ===== Hướng dẫn (lưới 2 cột) ===== */
.guide-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.guide-card { background: var(--white); border-radius: var(--r-lg); box-shadow: var(--sh-sm); overflow: hidden; color: inherit; display: flex; flex-direction: column; transition: transform .16s ease, box-shadow .16s ease; }
.guide-card:hover { transform: translateY(-2px); box-shadow: var(--sh-md); }
.guide-thumb { width: 100%; aspect-ratio: 1/1; background: linear-gradient(135deg, var(--blue-100), var(--pink-100)); overflow: hidden; }
.guide-thumb img { width: 100%; height: 100%; object-fit: cover; }
.guide-title { padding: 12px; font-size: 15px; font-weight: 700; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }

/* ===== Đọc bài hướng dẫn ===== */
.article-cover { width: 100%; aspect-ratio: 16/9; border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--sh-sm); margin-bottom: 16px; }
.article-cover img { width: 100%; height: 100%; object-fit: cover; }
.article-body { font-size: 16px; line-height: 1.7; }
.article-body h2 { font-size: 20px; font-weight: 800; margin: 18px 0 8px; }
.article-body p { margin: 0 0 12px; }
.article-body img { max-width: 100%; height: auto; border-radius: var(--r-md); margin: 12px 0; }
.article-body a { color: var(--blue-600); text-decoration: underline; }
.article-body ul, .article-body ol { margin: 0 0 12px 22px; }
.yt-embed { position: relative; padding-bottom: 56.25%; height: 0; margin: 14px 0; border-radius: var(--r-md); overflow: hidden; }
.yt-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ===== FAQ ===== */
.faq-list { display: flex; flex-direction: column; gap: 12px; }
.faq-item { background: var(--white); border-radius: var(--r-md); box-shadow: var(--sh-sm); overflow: hidden; }
.faq-q { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; text-align: left; padding: 16px; background: var(--white); color: var(--ink); border: 0; font: inherit; font-size: 16px; font-weight: 700; cursor: pointer; }
.faq-arrow { flex: 0 0 auto; transition: transform .2s ease; color: var(--blue); }
.faq-item.open .faq-arrow { transform: rotate(180deg); }
.faq-a { display: none; padding: 0 16px 16px; font-size: 15px; line-height: 1.6; white-space: pre-wrap; color: var(--muted); }
.faq-item.open .faq-a { display: block; }

/* ===== Bộ lọc (sheet) ===== */
.sheet-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: none; z-index: 50; }
.sheet-overlay.open { display: block; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto; background: var(--white); border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: 82vh; display: flex; flex-direction: column; z-index: 51; transform: translateY(100%); transition: transform .22s ease; }
.sheet.open { transform: translateY(0); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 16px; border-bottom: 1px solid var(--line); font-weight: 800; }
.sheet-head .x { border: 0; background: none; font-size: 20px; cursor: pointer; color: var(--muted); }
.sheet-body { padding: 16px; overflow-y: auto; }
.sheet-group { margin-bottom: 18px; }
.sheet-group h3 { font-size: 14px; font-weight: 800; margin-bottom: 8px; }
.sheet-foot { display: flex; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--line); }
.sheet-foot button { flex: 1; justify-content: center; padding: 13px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--white); color: var(--ink); font: inherit; font-size: 15px; font-weight: 700; cursor: pointer; }
.sheet-foot button.primary { background: var(--blue); color: #fff; border-color: var(--blue); box-shadow: var(--sh-blue); }
.sheet-foot button:active { transform: scale(.98); }

.opt-group { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { padding: 8px 14px; border-radius: var(--pill); border: 1px solid var(--line); font-size: 14px; font-weight: 700; cursor: pointer; user-select: none; background: var(--white); transition: background .15s, color .15s, border-color .15s; }
.opt.on { background: var(--blue); color: #fff; border-color: var(--blue); }
.opt-note { font-size: 13px; color: var(--muted); }

/* ===== Chi tiết game ===== */
.detail-gallery { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; margin-bottom: 16px; }
.detail-gallery::-webkit-scrollbar { display: none; }
.detail-gallery .slide { flex: 0 0 88%; scroll-snap-align: center; aspect-ratio: 16/9; border-radius: var(--r-lg); background: linear-gradient(135deg, var(--blue-100), var(--pink-100)); overflow: hidden; box-shadow: var(--sh-sm); }
.detail-gallery .slide img { width: 100%; height: 100%; object-fit: cover; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.badge { padding: 5px 12px; border-radius: var(--pill); background: var(--blue-50); color: var(--blue-600); font-size: 13px; font-weight: 700; }

.detail-info { background: var(--white); border-radius: var(--r-lg); box-shadow: var(--sh-sm); padding: 4px 16px; font-size: 15px; line-height: 1.6; }
.detail-info .row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.detail-info .row:last-child { border-bottom: 0; }
.detail-info .row .k { font-weight: 800; }
.detail-desc { margin: 16px 0; font-size: 16px; line-height: 1.7; white-space: pre-wrap; }

.guide-btn { display: block; width: 100%; text-align: center; margin-top: 24px; padding: 18px; border-radius: var(--r-md); background: var(--blue); color: #fff; font-size: 16px; font-weight: 800; box-shadow: var(--sh-blue); }
.guide-btn:active { transform: scale(.98); }

/* ===== Co giãn theo màn hình lớn (tablet / desktop) ===== */
@media (min-width: 600px) {
  .nav-grid { grid-template-columns: repeat(4, 1fr); }
  .cards { grid-template-columns: 1fr 1fr; }
  .guide-grid { grid-template-columns: repeat(3, 1fr); }
  .game-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 760px) {
  .game-grid { grid-template-columns: repeat(5, 1fr); }
  .shelf-card { flex: 0 0 148px; }
  .shelf-card .t { width: 148px; height: 148px; }
}
@media (min-width: 900px) {
  .game-grid { grid-template-columns: repeat(6, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
