:root { --ink: #1f1750; --muted: #6f6a94; --line: #e6e1f7; --soft: #f4f1fd; --deep: #140a6a; font-family: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif; color: var(--ink); background: var(--soft); font-synthesis: none; }
* { box-sizing: border-box; letter-spacing: 0; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100dvh; display: flex; flex-direction: column; }
a { color: inherit; text-decoration: none; }
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { font: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 3px solid #ffd34d; outline-offset: 4px; }
svg { width: 20px; height: 20px; flex-shrink: 0; stroke-width: 1.8; }

/* ---- đầu trang: nền tím than + ánh sáng màu + sao lấp lánh, màu lấy từ logo ---- */
.hero { position: relative; overflow: hidden; color: white; padding-bottom: 68px; border-radius: 0 0 36px 36px;
  background:
    radial-gradient(440px 260px at 84% 22%, rgba(255, 95, 168, .55), transparent 70%),
    radial-gradient(520px 300px at 10% 95%, rgba(63, 181, 255, .42), transparent 70%),
    radial-gradient(380px 220px at 52% -4%, rgba(255, 203, 71, .28), transparent 70%),
    linear-gradient(150deg, #140a6a 0%, #2a169b 48%, #5a24c4 100%); }
.sparks { position: absolute; inset: 84px 0 0 0; pointer-events: none; } /* chừa hàng logo/menu phía trên cho chữ dễ đọc */
.spark { position: absolute; width: var(--s, 16px); aspect-ratio: 1; background: var(--k, #ffd34d); opacity: .85; clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); animation: twinkle var(--d, 3s) ease-in-out infinite; animation-delay: var(--w, 0s); }
.spark:nth-child(1) { left: 5%; top: 46%; --s: 14px; --k: #fff; --d: 2.6s; }
.spark:nth-child(2) { left: 17%; top: 14%; --s: 22px; --k: #ffd34d; --d: 3.4s; --w: .6s; }
.spark:nth-child(3) { left: 36%; top: 64%; --s: 12px; --k: #7fd4ff; --d: 2.9s; --w: 1.1s; }
.spark:nth-child(4) { left: 52%; top: 18%; --s: 16px; --k: #fff; --d: 3.8s; --w: .3s; }
.spark:nth-child(5) { left: 66%; top: 60%; --s: 26px; --k: #ff8cc6; --d: 3.1s; --w: 1.6s; }
.spark:nth-child(6) { left: 78%; top: 12%; --s: 13px; --k: #ffd34d; --d: 2.7s; --w: .9s; }
.spark:nth-child(7) { left: 90%; top: 52%; --s: 18px; --k: #7fd4ff; --d: 3.6s; --w: 1.3s; }
.spark:nth-child(8) { left: 27%; top: 36%; --s: 9px; --k: #ff8cc6; --d: 2.4s; --w: 1.9s; }
.site-header { position: relative; z-index: 1; min-height: 80px; padding: 18px max(24px, calc((100vw - 1120px) / 2)); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.site-brand { display: inline-flex; align-items: center; gap: 12px; font-size: 24px; font-weight: 800; white-space: nowrap; text-shadow: 0 2px 12px rgba(10, 4, 70, .45); }
.brand-symbol { display: block; width: 44px; height: 44px; flex-shrink: 0; filter: drop-shadow(0 4px 10px rgba(255, 120, 200, .4)); }
.brand-symbol img { display: block; width: 100%; height: 100%; }
.nav-current { display: inline-flex; align-items: center; gap: 8px; color: white; font-size: 13px; font-weight: 650; padding: 8px 14px; border-radius: 999px; background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .28); }
.nav-current svg { color: #ffd34d; }
.hero-body { position: relative; z-index: 1; width: min(1120px, calc(100% - 48px)); margin: 20px auto 0; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.catalog-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; min-width: 0; }
h1 { margin: 0; font-size: clamp(34px, 6.4vw, 56px); line-height: 1.1; font-weight: 850; text-shadow: 0 3px 18px rgba(10, 4, 70, .45); }
.grad { background: linear-gradient(90deg, #ffd34d, #ff6fb1, #55c8ff, #ffd34d); background-size: 220% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: none; animation: shimmer 7s linear infinite; }
.game-count { color: #ece7ff; font-size: 13px; font-weight: 650; padding: 4px 12px; border-radius: 999px; background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .22); }
.game-count:empty { display: none; }
.hero-mascot { width: clamp(72px, 15vw, 136px); height: auto; flex-shrink: 0; filter: drop-shadow(0 10px 26px rgba(255, 120, 200, .5)); animation: float 5s ease-in-out infinite; }

/* ---- danh sách game: ô nhỏ nhiều màu, mỗi game một cặp màu riêng (đặt bằng --c1/--c2 trong hub.js) ---- */
.catalog { position: relative; z-index: 2; width: min(1120px, calc(100% - 48px)); margin: 0 auto 56px; flex: 1; }
.games-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.games-grid:not(:empty) { margin-top: -38px; }
.game-card { --c1: #7c3aed; --c2: #ec4899; position: relative; display: flex; flex-direction: column; background: white; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; min-width: 0; box-shadow: 0 8px 22px rgba(42, 22, 155, .12); transition: transform .18s, box-shadow .18s; }
.game-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: linear-gradient(90deg, var(--c1), var(--c2)); z-index: 1; }
.game-picture { display: block; aspect-ratio: 8 / 5; overflow: hidden; background: #e6f3f6; }
.game-picture img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .25s; }
.game-body { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; flex: 1; padding: 12px 14px 14px; min-width: 0; }
.game-category { display: inline-flex; align-items: center; gap: 6px; color: #5b2bd0; background: #efe9ff; font-size: 10.5px; font-weight: 750; padding: 3px 8px; border-radius: 999px; }
h2 { font-size: 23px; line-height: 1.3; margin: 12px 0 8px; }
.game-body h2 { font-size: 17px; line-height: 1.3; font-weight: 800; margin: 4px 0 0; max-width: 100%; overflow-wrap: anywhere; }
.game-tags { display: flex; flex-wrap: wrap; gap: 8px 6px; max-width: 100%; max-height: 21px; margin: 2px 0 10px; overflow: hidden; } /* chỉ 1 dòng: nhãn nào không vừa thì ẩn hẳn, không bị cắt dở */
.game-tags span { flex: 0 0 auto; color: var(--muted); background: var(--soft); font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.game-actions { display: flex; gap: 8px; width: 100%; margin-top: auto; }
.game-actions .button { min-height: 36px; padding: 6px 10px; font-size: 12.5px; gap: 6px; }
.game-actions .primary { flex: 1; min-width: 0; }
.game-actions .secondary { flex: 0 0 36px; width: 36px; padding: 0; }
.game-actions .secondary span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.game-actions svg { width: 16px; height: 16px; }
/* Game cần hai thiết bị (Vẽ Hình): hướng dẫn nằm ĐÈ LÊN phần dưới ảnh bìa (lớp tối mờ dần lên trên, hình nền vẫn thấy rõ) nên thẻ giữ nguyên kích thước như các game khác;
   hai nút Xem / Vẽ chung một hàng. Chữ hướng dẫn và nhãn nút lấy từ games.json (howTo, screenLabel/playLabel). */
.game-picture { position: relative; }
.game-howto { position: absolute; inset: auto 0 0 0; margin: 0; padding: 22px 12px 9px; list-style: none; counter-reset: step; display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; background: linear-gradient(to top, rgba(18, 10, 84, .78) 0%, rgba(18, 10, 84, .58) 60%, rgba(18, 10, 84, 0) 100%); color: #fff; font-size: 11.5px; font-weight: 700; line-height: 1.32; text-shadow: 0 1px 3px rgba(0, 0, 0, .7), 0 0 2px rgba(0, 0, 0, .5); pointer-events: none; }
.game-howto li { counter-increment: step; display: flex; gap: 8px; align-items: flex-start; }
.game-howto li::before { content: counter(step); flex: 0 0 18px; height: 18px; margin-top: 0; display: grid; place-items: center; border-radius: 50%; background: var(--c1); background: linear-gradient(135deg, var(--c1), var(--c2)); color: #fff; font-size: 11px; font-weight: 800; text-shadow: none; }
.game-howto b { font-weight: 800; color: #ffe27a; }
.game-actions.pair { gap: 8px; }
.game-actions.pair .choice { flex: 1 1 0; width: auto; min-width: 0; padding: 6px 10px; justify-content: center; }
.game-actions.pair .secondary.choice { background: white; border-color: var(--line); color: var(--ink); }
.game-actions.pair .secondary.choice:hover { background: var(--soft); }
.game-actions.pair .choice .choice-text { position: static; width: auto; height: auto; overflow: visible; clip: auto; white-space: nowrap; }
@media (max-width: 520px) { .game-howto { font-size: 13px; padding: 28px 14px 11px; gap: 8px; } .game-howto li::before { flex-basis: 20px; height: 20px; font-size: 12px; } }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 10px 14px; border: 1px solid transparent; border-radius: 10px; font-size: 13px; font-weight: 700; }
.primary { color: white; background: #137c72; }
.game-card .primary { background: var(--c1); background: linear-gradient(135deg, var(--c1), var(--c2)); box-shadow: 0 4px 12px rgba(42, 22, 155, .18); transition: filter .15s, transform .15s; }
.primary:hover { filter: brightness(1.08); }
.secondary { background: white; border-color: #d9d2f3; color: #5b4fb0; }
.secondary:hover { background: #f4f1fd; }
.soon-card { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 120px; padding: 18px; border: 2px dashed #c9bdf2; border-radius: 16px; background: #faf8ff; color: #7a63c9; font-size: 13px; font-weight: 700; text-align: center; }
.soon-card svg { width: 26px; height: 26px; color: #ec4899; }
.catalog-state { margin-top: 20px; color: var(--muted); font-size: 14px; }
.catalog-state p:empty { display: none; }
.site-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 22px max(24px, calc((100vw - 1120px) / 2)); background: #1a0e78; color: #b9b0f5; font-size: 12px; }
.site-footer svg { color: #ffd34d; }

@media (hover: hover) {
  .game-card:hover { transform: translateY(-5px); box-shadow: 0 16px 34px rgba(42, 22, 155, .22); }
  .game-card:hover .game-picture img { transform: scale(1.05); }
  .game-card .primary:hover { transform: translateY(-1px); }
}
@supports (color: color-mix(in srgb, red, blue)) {
  .game-card:hover { box-shadow: 0 16px 34px color-mix(in srgb, var(--c1) 32%, transparent); }
  .game-category { color: color-mix(in srgb, var(--c1) 80%, #000); background: color-mix(in srgb, var(--c1) 13%, #fff); }
  .game-card .primary { box-shadow: 0 4px 12px color-mix(in srgb, var(--c1) 35%, transparent); }
  .secondary { color: color-mix(in srgb, var(--c1, #5b4fb0) 85%, #000); }
}
/* thẻ game hiện dần khi cuộn tới (lớp do hub.js gắn) */
.reveal { opacity: 0; }
.reveal-in { animation: card-in .5s cubic-bezier(.2, .8, .2, 1) var(--d, 0ms) backwards; }
@keyframes card-in { from { opacity: 0; transform: translateY(22px) scale(.97); } }
@keyframes twinkle { 0%, 100% { opacity: .25; transform: scale(.7) rotate(0deg); } 50% { opacity: 1; transform: scale(1.1) rotate(20deg); } }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-10px) rotate(3deg); } }
@keyframes shimmer { to { background-position: -220% 0; } }

@media (max-width: 760px) {
  .hero { padding-bottom: 56px; border-radius: 0 0 28px 28px; }
  .site-header { padding: 16px; min-height: 72px; gap: 10px; }
  .site-brand { font-size: 20px; gap: 9px; }
  .brand-symbol { width: 36px; height: 36px; }
  .nav-current { font-size: 11.5px; gap: 6px; padding: 7px 12px; border-radius: 16px; }
  .nav-current svg { width: 17px; height: 17px; }
  .hero-body { width: calc(100% - 32px); margin-top: 10px; }
  .catalog { width: calc(100% - 32px); margin-bottom: 40px; }
  .games-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .games-grid:not(:empty) { margin-top: -32px; }
  /* Ảnh bìa là 8:5: giữ nguyên tỉ lệ và nằm trên đầu thẻ (đừng nhét vào cột 104px, sẽ bị cắt mất phần lớn hình) */
  .game-body { padding: 10px 12px 12px; }
  .soon-card { flex-direction: row; min-height: 64px; padding: 12px; }
  .site-footer { padding: 20px 16px; }
}
@media (min-width: 520px) and (max-width: 760px) { .games-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } } /* máy tính bảng dọc: hai cột cho ảnh bìa khỏi quá to */
@media (max-width: 420px) { .nav-current svg { display: none; } .nav-current { min-width: 0; } }
@media (max-width: 360px) { .site-brand { font-size: 18px; } }
@media (prefers-reduced-motion: reduce) { .spark, .hero-mascot, .grad { animation: none; } .spark { opacity: .7; } .game-card, .game-picture img, .game-card .primary { transition: none; } }

/* ---- nút đăng nhập / tài khoản (auth.js) ---- */
.account-slot { display: flex; align-items: center; margin-left: auto; }
.site-header nav + .account-slot { margin-left: 12px; }
@media (max-width: 560px) { .site-header { flex-wrap: wrap; row-gap: 8px; } .site-brand { order: 1; } .account-slot { order: 2; margin-left: auto; } .site-header nav { order: 3; flex-basis: 100%; } } /* điện thoại: logo + nút tài khoản cùng một hàng, dòng giới thiệu xuống dưới */
