:root {
  --bg: #f6f7f9;
  --bg-soft: #ffffff;
  --card: #ffffff;
  --card-hover: #fff5f4;
  --border: #e5e7eb;
  --text: #1c1c28;
  --muted: #6b7280;
  --accent: #e2231a;
  --accent-dark: #b3120b;
  --accent-2: #ff5f52;
  --gold: #d97706;
  --danger: #e11d48;
  --success: #16a34a;
  --radius: 14px;
  --header-h: 72px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
  background:
    radial-gradient(1200px 500px at 80% -100px, rgba(226, 35, 26, 0.06), transparent 60%),
    radial-gradient(900px 400px at 10% 0, rgba(226, 35, 26, 0.04), transparent 60%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
img { display: block; }

.container { max-width: 1420px; margin: 0 auto; padding: 0 28px; }

/* ===== Header (đỏ, chữ trắng) ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: linear-gradient(120deg, var(--accent-dark), var(--accent));
  box-shadow: 0 4px 18px rgba(226, 35, 26, 0.28);
}

.header-inner {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 28px;
}

.logo { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.logo img { height: 24px; }

.main-nav { display: flex; gap: 6px; }

.main-nav a {
  padding: 10px 16px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.78);
  border-radius: 10px;
  position: relative;
  transition: color 0.15s;
}
.main-nav a:hover { color: #fff; }
.main-nav a.active { color: #fff; }
.main-nav a.active::after {
  content: '';
  position: absolute;
  left: 16px; right: 16px; bottom: 2px;
  height: 3px;
  border-radius: 2px;
  background: #fff;
}

.header-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
#userArea { display: flex; align-items: center; gap: 12px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 999px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, background 0.15s;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* nút trắng chữ đỏ — dùng trên nền đỏ (header, hero) */
.btn-light {
  background: #fff;
  color: var(--accent);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
}

/* nút viền trắng mờ — dùng trên nền đỏ */
.btn-ghost {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.45);
  color: #fff;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.22); }

.btn-primary {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 6px 18px rgba(226, 35, 26, 0.35);
}

.btn-gold {
  background: linear-gradient(120deg, #f5b942, #ff8a3d);
  color: #221500;
  box-shadow: 0 6px 18px rgba(245, 185, 66, 0.3);
}

.btn-block { width: 100%; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-sm { padding: 7px 14px; font-size: 13px; }

/* balance chip + user menu (trên header đỏ) */
.balance-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.45);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
.balance-chip .plus {
  width: 20px; height: 20px;
  display: grid; place-items: center;
  background: #fff;
  color: var(--accent);
  border-radius: 50%;
  font-weight: 800;
}

.user-menu { position: relative; }
.user-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.45);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.user-menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 190px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.16);
  display: none;
}
.user-menu.open .user-menu-dropdown { display: block; }
.user-menu-dropdown a,
.user-menu-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 14px;
  border-radius: 8px;
  cursor: pointer;
}
.user-menu-dropdown a:hover,
.user-menu-dropdown button:hover { background: #f3f4f6; }
.user-menu-dropdown .danger { color: var(--danger); }

/* ===== Banner slider (trang chủ) ===== */
.banner-slider {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  margin-top: 26px;
  aspect-ratio: 1024 / 312;
  background: #fff;
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.12);
}
.bs-track {
  display: flex;
  height: 100%;
  transition: transform 0.5s ease;
}
.bs-track img {
  width: 100%;
  height: 100%;
  flex-shrink: 0;
  object-fit: cover;
}
.bs-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 42px; height: 42px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.32);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}
.banner-slider:hover .bs-arrow { opacity: 1; }
.bs-arrow:hover { background: rgba(0, 0, 0, 0.55); }
.bs-prev { left: 14px; }
.bs-next { right: 14px; }
.bs-dots {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}
.bs-dots button {
  width: 9px; height: 9px;
  border-radius: 999px;
  border: none;
  background: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  transition: all 0.2s;
}
.bs-dots button.active { width: 26px; background: #fff; }

/* ===== Section ===== */
.section { margin-top: 52px; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 16px;
  flex-wrap: wrap;
}
.section-head h2 { font-size: 26px; letter-spacing: -0.3px; }
.section-head .see-all { color: var(--accent); font-weight: 600; font-size: 14px; }

.page-title { font-size: 30px; margin: 34px 0 22px; letter-spacing: -0.4px; }

/* ===== Filter bar (danh sách game) ===== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}

.chip {
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover { color: var(--accent); border-color: var(--accent-2); }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.search-box {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 18px;
  min-width: 300px;
}
.search-box svg { flex-shrink: 0; opacity: 0.55; }
.search-box input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 14px;
  width: 100%;
}
.search-box input::placeholder { color: var(--muted); }

/* ===== Game grid ===== */
.game-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 26px 22px;
}
@media (max-width: 1200px) { .game-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 980px) { .game-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px) { .game-grid { grid-template-columns: repeat(2, 1fr); } }

.game-card { display: block; }
.game-card .cover-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 3 / 4;
  border: 1px solid var(--border);
  background: #fff;
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
}
.game-card:hover .cover-wrap {
  transform: translateY(-5px);
  border-color: var(--accent-2);
  box-shadow: 0 18px 40px rgba(226, 35, 26, 0.18);
}
.game-card .cover-wrap img { width: 100%; height: 100%; object-fit: cover; }

/* icon vuông: bo sâu theo đúng độ cong của ảnh app icon */
.cover-wrap.square { aspect-ratio: 1 / 1; border-radius: 21%; }

/* ribbon giảm giá chéo góc trên PHẢI icon */
.ribbon {
  position: absolute;
  top: 22px; right: -38px;
  width: 150px;
  transform: rotate(45deg);
  text-align: center;
  padding: 6px 0;
  background: linear-gradient(120deg, #ff4d4d, var(--accent));
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 14px rgba(226, 35, 26, 0.45);
  pointer-events: none;
}

.game-card h3 {
  margin-top: 14px;
  font-size: 16.5px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.game-card .meta {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}
.star { color: var(--gold); }
.dot { width: 3px; height: 3px; border-radius: 50%; background: var(--muted); }

.empty-note {
  padding: 60px 0;
  text-align: center;
  color: var(--muted);
  grid-column: 1 / -1;
}

/* ===== Bảng nạp mở ngay trong danh sách (accordion) ===== */
.inline-topup {
  grid-column: 1 / -1;
  animation: panelIn 0.22s ease;
}
@keyframes panelIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}
.inline-topup .topup-panel { margin-top: 0; }

.topup-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.topup-head img {
  width: 60px; height: 60px;
  border-radius: 21%;
  object-fit: cover;
  border: 1px solid var(--border);
}
.topup-head .th-info { flex: 1; min-width: 0; }
.topup-head h2 { font-size: 20px; }
.topup-head .th-meta { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.topup-close {
  border: none;
  background: #f3f4f6;
  width: 36px; height: 36px;
  border-radius: 50%;
  cursor: pointer;
  color: var(--muted);
  font-size: 15px;
  flex-shrink: 0;
}
.topup-close:hover { background: #e5e7eb; }

.game-card.open .cover-wrap {
  border-color: var(--accent);
  box-shadow: 0 10px 26px rgba(226, 35, 26, 0.22);
}
.game-card.open h3 { color: var(--accent); }

/* ===== Steps (trang chủ) ===== */
.steps-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}
@media (max-width: 980px) { .steps-grid { grid-template-columns: repeat(2, 1fr); } }
.step-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 22px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}
.step-card .num {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 12px;
  font-weight: 800;
  font-size: 17px;
  color: #fff;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  margin-bottom: 16px;
}
.step-card h3 { font-size: 16px; margin-bottom: 8px; }
.step-card p { color: var(--muted); font-size: 14px; line-height: 1.55; }

/* ===== Trang chi tiết game ===== */
.game-hero {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 36px;
  margin-top: 34px;
}
@media (max-width: 860px) { .game-hero { grid-template-columns: 1fr; } }

.game-hero .cover {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #fff;
  aspect-ratio: 3 / 4;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}
.game-hero .cover.square { aspect-ratio: 1 / 1; align-self: start; border-radius: 21%; }
.game-hero .cover img { width: 100%; height: 100%; object-fit: cover; }

.game-hero .info h1 { font-size: 34px; letter-spacing: -0.4px; }
.game-hero .info .meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 18px;
  color: var(--muted);
  font-size: 15px;
}
.game-hero .info .desc { color: var(--muted); line-height: 1.65; max-width: 640px; }

.crumb { margin-top: 26px; color: var(--muted); font-size: 14px; }
.crumb a:hover { color: var(--accent); }

/* topup panel */
.topup-panel {
  margin-top: 40px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.05);
}
.topup-panel h2 { font-size: 21px; margin-bottom: 4px; }
.topup-panel .sub { color: var(--muted); font-size: 14px; margin-bottom: 22px; }

.step-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  margin: 26px 0 14px;
}
.step-label .n {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  font-size: 13px;
  font-weight: 800;
}

.pkg-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
@media (max-width: 900px) { .pkg-grid { grid-template-columns: repeat(2, 1fr); } }

.pkg-card {
  position: relative;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.pkg-card:hover { background: var(--card-hover); }
.pkg-card.selected { border-color: var(--accent); background: #fff1f0; }
.pkg-card .pkg-label { font-weight: 700; font-size: 15.5px; }
.pkg-card .pkg-price { margin-top: 8px; color: var(--accent); font-weight: 800; font-size: 17px; }
.pkg-card .pkg-old { color: var(--muted); font-weight: 600; font-size: 13.5px; margin-right: 4px; }
.pkg-card .pkg-bonus {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--success);
  background: rgba(22, 163, 74, 0.1);
  padding: 3px 10px;
  border-radius: 999px;
}
.pkg-card .pkg-hot {
  position: absolute;
  top: -9px; right: 12px;
  background: linear-gradient(120deg, #ff4d4d, var(--accent));
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 999px;
}
.pkg-card .tick {
  position: absolute;
  bottom: 12px; right: 12px;
  width: 22px; height: 22px;
  border-radius: 50%;
  display: none;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
}
.pkg-card.selected .tick { display: grid; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 700px) { .form-row { grid-template-columns: 1fr; } }

.field label { display: block; font-size: 13.5px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.field input, .field select {
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  padding: 13px 16px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus, .field select:focus { border-color: var(--accent); }

.order-summary {
  margin-top: 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
}
.order-summary .total-label { color: var(--muted); font-size: 14px; }
.order-summary .total-value { font-size: 24px; font-weight: 800; color: var(--accent); }

/* ===== Bảng lịch sử ===== */
.table-wrap {
  overflow-x: auto;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th, td { text-align: left; padding: 14px 18px; white-space: nowrap; }
thead th {
  color: var(--muted);
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
tbody tr { border-bottom: 1px solid #f0f1f3; }
tbody tr:last-child { border-bottom: none; }
.status-pill {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
}
.status-success { background: rgba(22, 163, 74, 0.1); color: var(--success); }
.code-cell { font-family: Consolas, monospace; color: var(--accent); }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(28, 28, 40, 0.5);
  backdrop-filter: blur(6px);
}
.modal-overlay.open { display: flex; }

.modal {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 30px;
  position: relative;
  animation: modalIn 0.18s ease;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.2);
}
.modal.wide { max-width: 520px; }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.modal .close-x {
  position: absolute;
  top: 16px; right: 16px;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: #f3f4f6;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
}
.modal h3 { font-size: 21px; margin-bottom: 4px; }
.modal .modal-sub { color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.modal .field { margin-bottom: 14px; }
.modal .form-error {
  display: none;
  margin-bottom: 12px;
  color: var(--danger);
  background: rgba(225, 29, 72, 0.07);
  border: 1px solid rgba(225, 29, 72, 0.25);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13.5px;
}
.modal .form-error.show { display: block; }

.amount-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.amount-grid button {
  padding: 14px 8px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: #fff;
  color: var(--text);
  font-weight: 700;
  font-size: 14.5px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.amount-grid button.selected { border-color: var(--accent); color: var(--accent); background: #fff1f0; }

.demo-note {
  font-size: 12.5px;
  color: var(--muted);
  background: #f9fafb;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 18px;
  line-height: 1.5;
}

/* success modal */
.success-icon {
  width: 64px; height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 30px;
  background: rgba(22, 163, 74, 0.1);
  border: 1px solid rgba(22, 163, 74, 0.35);
}
.order-detail-list { margin: 18px 0; }
.order-detail-list .row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 14.5px;
}
.order-detail-list .row span:first-child { color: var(--muted); }
.order-detail-list .row.code b { font-family: Consolas, monospace; color: var(--accent); letter-spacing: 1px; }

/* ===== Toast ===== */
#toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  background: #1c1c28;
  color: #fff;
  padding: 13px 24px;
  border-radius: 999px;
  font-size: 14.5px;
  font-weight: 600;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.3);
  transition: opacity 0.25s, transform 0.25s;
}
#toast.hidden { opacity: 0; transform: translateX(-50%) translateY(16px); pointer-events: none; }

/* ===== Footer ===== */
.site-footer {
  margin-top: 80px;
  border-top: 1px solid var(--border);
  padding: 40px 0 50px;
  color: var(--muted);
  font-size: 14px;
  background: #fff;
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  align-items: center;
}
.footer-links { display: flex; gap: 22px; flex-wrap: wrap; }
.footer-links a:hover { color: var(--accent); }

/* responsive header */
@media (max-width: 760px) {
  .main-nav { display: none; }
  .banner-slider { border-radius: 14px; }
  .search-box { min-width: 0; width: 100%; margin-left: 0; }
  .container { padding: 0 18px; }
}

.hidden { display: none !important; }
