:root {
  --bg: #0b0a10;
  --panel: rgba(18, 16, 26, 0.72);
  --panel-solid: #15131d;
  --line: rgba(255, 255, 255, 0.10);
  --line-strong: rgba(255, 255, 255, 0.22);
  --text: #f4f1ea;
  --muted: #a9a3b4;
  --faint: #6f6a7a;
  --gold-1: #fff3c4;
  --gold-2: #f2c25a;
  --gold-3: #b9792a;
  --ios: #e8e6ef;
  --android: #3ddc84;
  --radius: 14px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font: 15px/1.55 "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
img { display: block; }

/* ---------- Nền: icon game phóng to, làm mờ + tia sáng — thay cho key art ---------- */
.stage { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.stage { background: radial-gradient(circle at 60% 40%, #3a2a14, #0b0a10 70%); }
.stage-art {
  position: absolute; inset: -12%; width: 124%; height: 124%; object-fit: cover;
  filter: blur(70px) saturate(1.5) brightness(0.75); transform: scale(1.1); opacity: 0.85;
}
.stage-art[hidden] { display: none; }
.stage-rays {
  position: absolute; inset: 0;
  background:
    conic-gradient(from 200deg at 62% 38%, transparent 0 8%, rgba(255, 214, 120, 0.10) 10%, transparent 14% 22%, rgba(255, 214, 120, 0.08) 25%, transparent 30% 100%),
    radial-gradient(60% 50% at 62% 35%, rgba(255, 200, 90, 0.18), transparent 70%);
  mix-blend-mode: screen;
}
.stage-shade {
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgba(11, 10, 16, 0.25) 0%, rgba(11, 10, 16, 0.55) 45%, var(--bg) 92%),
    radial-gradient(120% 80% at 50% 0%, transparent 40%, rgba(0, 0, 0, 0.55) 100%);
}
.stage-grain {
  position: absolute; inset: 0; opacity: 0.06;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.page { position: relative; z-index: 1; max-width: 1240px; margin: 0 auto; padding: 0 24px 48px; }

/* ---------- Thanh trên ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 22px 0; }
.brand { display: inline-flex; align-items: center; gap: 14px; text-decoration: none; }
.brand img { height: 54px; width: auto; filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.45)); }
.brand span { padding-left: 14px; border-left: 1px solid var(--line-strong); font: 600 15px/1 "Oswald", sans-serif; letter-spacing: 0.38em; color: var(--gold-2); }
.top-right { display: flex; align-items: center; gap: 12px; min-width: 0; }
.search[hidden], .me[hidden] { display: none; }
.me { display: flex; align-items: center; gap: 10px; padding: 4px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line); }
.me img, .me .ph { width: 32px; height: 32px; border-radius: 50%; font-size: 13px; }
.me span { font-size: 13px; color: var(--muted); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me button { border: 0; background: rgba(255, 255, 255, 0.10); color: var(--text); height: 30px; padding: 0 12px; border-radius: 999px; cursor: pointer; font-size: 12px; font-weight: 600; }
.me button:hover { background: rgba(255, 255, 255, 0.18); }

/* ---------- Đăng nhập ---------- */
.login { display: grid; place-items: center; padding: 72px 0 96px; }
.login-card { width: min(420px, 100%); padding: 36px 32px; border-radius: 22px; text-align: center; background: var(--panel); border: 1px solid var(--line-strong); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: var(--shadow); }
.login-card img.logo { height: 64px; width: auto; margin: 0 auto 18px; }
.login-card h1 { margin: 0 0 6px; font: 700 30px/1.1 "Oswald", sans-serif; letter-spacing: 0.04em; text-transform: uppercase; background: linear-gradient(180deg, var(--gold-1), var(--gold-2) 55%, var(--gold-3)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-card p { margin: 0 0 24px; color: var(--muted); font-size: 14px; }
.login-card p b { color: var(--text); font-weight: 600; }
.gsi { display: flex; justify-content: center; min-height: 44px; }
.login-error { margin: 16px 0 0; padding: 10px 12px; border-radius: 10px; background: rgba(207, 19, 34, 0.14); border: 1px solid rgba(207, 19, 34, 0.35); color: #ffb3b8; font-size: 13px; }
.login-error[hidden] { display: none; }

.search {
  display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 16px; min-width: 0; width: min(320px, 50vw);
  border-radius: 999px; background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.search svg { flex-shrink: 0; opacity: 0.6; }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--text); font: inherit; }
.search input::placeholder { color: var(--muted); }
.search:focus-within { border-color: var(--line-strong); background: rgba(255, 255, 255, 0.12); }

/* ---------- Dải chọn game ---------- */
.rail { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 14px; scrollbar-width: thin; scroll-snap-type: x proximity; }
.rail[hidden] { display: none; }
.rail::-webkit-scrollbar { height: 6px; }
.rail::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 3px; }
.game {
  flex: 0 0 auto; display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 8px; max-width: 240px;
  border-radius: 14px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; text-align: left;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); scroll-snap-align: start;
  transition: border-color 0.2s, transform 0.2s, background 0.2s;
}
.game:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.game.is-empty img, .game.is-empty .ph { filter: grayscale(0.6); opacity: 0.75; }
.game[aria-current="true"] { border-color: var(--gold-2); background: rgba(242, 194, 90, 0.12); box-shadow: 0 0 0 1px rgba(242, 194, 90, 0.35) inset; }
.game img, .game .ph { width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0; object-fit: cover; }
.game span { display: flex; flex-direction: column; min-width: 0; }
.game b { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game small { color: var(--muted); font-size: 12px; white-space: nowrap; }
.ph { display: grid; place-items: center; background: linear-gradient(135deg, #3a3350, #1d1a28); font: 700 16px "Oswald", sans-serif; color: var(--gold-2); }

/* ---------- Hero ---------- */
.hero { display: grid; grid-template-columns: auto 1fr; gap: 40px; align-items: center; padding: 56px 0 64px; }
.hero-icon { position: relative; }
.hero-icon img, .hero-icon .ph {
  width: 196px; height: 196px; border-radius: 44px; object-fit: cover; font-size: 64px;
  box-shadow: var(--shadow), 0 0 0 1px rgba(255, 255, 255, 0.12);
}
.hero-icon::after {
  content: ""; position: absolute; inset: -18px; border-radius: 60px; z-index: -1;
  background: radial-gradient(closest-side, rgba(242, 194, 90, 0.35), transparent);
}
.eyebrow { margin: 0 0 6px; font: 600 13px/1 "Oswald", sans-serif; letter-spacing: 0.3em; text-transform: uppercase; color: var(--gold-2); }
.title {
  margin: 0; font: 700 clamp(40px, 6.4vw, 84px)/0.98 "Oswald", sans-serif; text-transform: uppercase; letter-spacing: 0.01em;
  background: linear-gradient(180deg, var(--gold-1) 0%, var(--gold-2) 48%, var(--gold-3) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 18px rgba(0, 0, 0, 0.55)); overflow-wrap: anywhere;
}
.meta { margin: 14px 0 0; color: var(--muted); font-size: 14px; letter-spacing: 0.02em; }
.meta b { color: var(--text); font-weight: 600; }

.dl { display: flex; align-items: stretch; gap: 14px; margin-top: 28px; flex-wrap: wrap; }
.qr {
  width: 142px; height: 142px; padding: 10px; border-radius: 12px; background: #fff; flex-shrink: 0;
  box-shadow: var(--shadow); display: grid; place-items: center;
}
.qr { position: relative; }
.qr svg { width: 100%; height: 100%; display: block; }
/* Logo giữa QR (QR dùng mức sửa lỗi H nên vẫn quét được) */
.qr-logo { position: absolute; left: 50%; top: 50%; width: 24%; height: 24%; transform: translate(-50%, -50%); }
.qr-cap { margin-top: 8px; font-size: 12px; color: var(--muted); text-align: center; }
.badges { display: grid; grid-template-columns: repeat(2, minmax(220px, 1fr)); gap: 12px; align-content: start; }
.badge {
  display: flex; align-items: center; gap: 14px; height: 64px; padding: 0 20px; border-radius: 12px; text-decoration: none;
  background: #000; border: 1px solid rgba(255, 255, 255, 0.28); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s; cursor: pointer;
}
.badge:hover { transform: translateY(-2px); border-color: rgba(255, 255, 255, 0.6); }
.badge:focus-visible, .game:focus-visible, .seg button:focus-visible, .row-btn:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 2px; }
.badge svg { width: 30px; height: 30px; flex-shrink: 0; }
.badge span { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; text-align: left; }
.badge small { font-size: 11px; color: #cfcbd8; letter-spacing: 0.02em; }
.badge b { font-size: 20px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge.is-preferred { border-color: var(--gold-2); box-shadow: 0 0 0 1px var(--gold-2), 0 12px 34px rgba(242, 194, 90, 0.18); }
.badge[aria-disabled="true"] { opacity: 0.42; cursor: not-allowed; transform: none; border-color: rgba(255, 255, 255, 0.14); }
.hint { margin: 14px 0 0; font-size: 13px; color: var(--muted); max-width: 640px; }
.hint strong { color: var(--gold-1); font-weight: 600; }

/* ---------- Danh sách phiên bản ---------- */
.history { border-radius: 20px; background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); overflow: hidden; }
.history-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.history-head h2 { margin: 0; font: 600 22px/1.1 "Oswald", sans-serif; letter-spacing: 0.04em; text-transform: uppercase; }
.history-head h2 small { font: 500 14px "Be Vietnam Pro", sans-serif; color: var(--muted); text-transform: none; letter-spacing: 0; margin-left: 8px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); }
.seg button { border: 0; background: none; padding: 6px 14px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 500; font-size: 14px; }
.seg button[aria-pressed="true"] { background: rgba(255, 255, 255, 0.14); color: var(--text); }

.versions { list-style: none; margin: 0; padding: 0; }
.ver {
  display: grid; grid-template-columns: 96px minmax(140px, 200px) 1fr 90px auto; gap: 16px; align-items: center;
  padding: 14px 24px; border-bottom: 1px solid var(--line);
}
.ver:last-child { border-bottom: 0; }
.ver:hover { background: rgba(255, 255, 255, 0.03); }
.chip { display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: 92px; height: 26px; border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: 0.02em; }
.chip svg { width: 13px; height: 13px; }
.chip.ios { background: rgba(232, 230, 239, 0.12); color: var(--ios); }
.chip.android { background: rgba(61, 220, 132, 0.12); color: var(--android); }
.ver-v { display: flex; flex-direction: column; min-width: 0; }
.ver-v b { font-size: 16px; font-weight: 700; white-space: nowrap; }
.ver-v time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.latest { display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 6px; font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #1b1406; background: var(--gold-2); vertical-align: 2px; }
.ver-note { color: var(--muted); font-size: 13px; min-width: 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ver-size { color: var(--muted); font-size: 13px; text-align: right; white-space: nowrap; }
.ver-actions { display: flex; gap: 8px; justify-content: flex-end; }
.row-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--line-strong); background: rgba(255, 255, 255, 0.06); text-decoration: none; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.row-btn:hover { background: rgba(255, 255, 255, 0.14); }
.row-btn.primary { background: var(--text); color: #111; border-color: var(--text); }
.row-btn.primary:hover { background: #fff; }
.row-btn svg { width: 15px; height: 15px; }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); }

/* ---------- Modal QR ---------- */
.modal { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 16px; background: rgba(5, 4, 8, 0.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.modal[hidden] { display: none; }
.modal-card { width: min(360px, 100%); padding: 24px; border-radius: 20px; background: var(--panel-solid); border: 1px solid var(--line-strong); box-shadow: var(--shadow); text-align: center; }
.modal-card h3 { margin: 0 0 4px; font: 600 20px "Oswald", sans-serif; letter-spacing: 0.03em; }
.modal-card p { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.modal-card .qr { width: 220px; height: 220px; margin: 0 auto 16px; }
.modal-card .row-btn { margin: 0 4px; }

footer { margin-top: 36px; color: var(--faint); font-size: 12px; text-align: center; line-height: 1.7; }

.state { padding: 120px 0; text-align: center; color: var(--muted); }
.state h1 { font: 600 28px "Oswald", sans-serif; color: var(--text); letter-spacing: 0.04em; margin: 0 0 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 24px; padding: 32px 0 40px; text-align: center; justify-items: center; }
  .hero-icon img, .hero-icon .ph { width: 132px; height: 132px; border-radius: 30px; font-size: 44px; }
  .dl { justify-content: center; }
  .hint { margin-left: auto; margin-right: auto; }
  .ver { grid-template-columns: 96px 1fr auto; grid-template-areas: "chip v actions" "note note note"; row-gap: 6px; }
  .ver .chip { grid-area: chip; }
  .ver-v { grid-area: v; }
  .ver-actions { grid-area: actions; }
  .ver-note { grid-area: note; }
  .ver-size { display: none; }
}
@media (max-width: 600px) {
  .page { padding: 0 16px 32px; }
  .top { padding: 16px 0; }
  .brand { gap: 10px; }
  .brand img { height: 36px; }
  .brand span { padding-left: 10px; font-size: 13px; letter-spacing: 0.3em; }
  .search { width: 40vw; height: 38px; padding: 0 12px; }
  .me span { display: none; }
  .badges { grid-template-columns: 1fr; width: 100%; }
  .badge { justify-content: center; }
  .dl .qr-wrap { display: none; } /* trên điện thoại bấm thẳng nút, QR không cần */
  .history-head, .ver { padding-left: 16px; padding-right: 16px; }
  /* Chip chỉ còn icon để version + ngày đủ chỗ trên một dòng */
  .ver { grid-template-columns: 30px 1fr auto; gap: 12px; }
  .ver .chip { width: 30px; height: 30px; padding: 0; font-size: 0; }
  .ver .chip svg { width: 15px; height: 15px; }
  .row-btn { padding: 0 12px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
