:root {
  --bg: #f0f2f7;
  --bg2: #ffffff;
  --border: rgba(0, 0, 0, 0.09);
  --text: #1a1a2e;
  --muted: #6b7280;
  --amber: #f59e0b;
  --orange: #f97316;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── HEADER ── */
#mtg-header {
  position: sticky;
  top: 0;
  z-index: 999;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 1px 0 var(--border);
}

.hd-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
  padding: 0 20px;
  gap: 12px;
}

/* Logo */
.logo {
  font-size: 15px;
  font-weight: 900;
  letter-spacing: -.5px;
  background: linear-gradient(90deg, #f59e0b, #f97316);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-decoration: none;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
}

.logo-brand {
  background: linear-gradient(90deg, #f59e0b, #f97316);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.logo-sep {
  color: rgba(0, 0, 0, 0.2);
  font-weight: 300;
  font-size: 13px;
  margin: 0 5px;
  -webkit-text-fill-color: rgba(0, 0, 0, 0.2);
}
.logo-page {
  color: var(--muted);
  -webkit-text-fill-color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0;
}

/* ── CENTER GAME NAV (PC only) ── */
.hd-center {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  justify-content: center;
  overflow: hidden;
}

@media (max-width: 768px) {
  .hd-center { display: none; }
  #hdCartChatWrap { display: none !important; }
}

.hd-game-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 5px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  transition: background .15s, color .15s, box-shadow .15s;
  white-space: nowrap;
  border: 1px solid transparent;
}
.hd-game-link:hover  { background: rgba(245,158,11,.08); color: #d97706; border-color: rgba(245,158,11,.2); }
.hd-game-link.active { background: rgba(245,158,11,.1);  color: #d97706; border-color: rgba(245,158,11,.25); box-shadow: 0 1px 6px rgba(245,158,11,.12); }

.hd-game-thumb {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  object-fit: cover;
  flex-shrink: 0;
  background: #e5e7eb;
}
.hd-game-thumb-ph {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, #f59e0b22, #f9731622);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

/* ── MOBILE GAME NAV (dưới header) ── */
.mobile-game-nav {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  gap: 6px;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 58px;
  z-index: 998;
}
.mobile-game-nav::-webkit-scrollbar { display: none; }

@media (max-width: 768px) {
  .mobile-game-nav { display: flex; }
}

.mob-game-link {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px 5px 5px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid transparent;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.mob-game-link:hover  { background: rgba(245,158,11,.08); color: #d97706; border-color: rgba(245,158,11,.2); }
.mob-game-link.active { background: rgba(245,158,11,.1);  color: #d97706; border-color: rgba(245,158,11,.25); }

.mob-game-thumb {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: #e5e7eb;
}
.mob-game-thumb-ph {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: linear-gradient(135deg, #f59e0b22, #f9731622);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}

/* ── USER BOX ── */
#userBox { display: flex; align-items: center; flex-shrink: 0; }

.btn-login {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  height: 34px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(90deg, #f59e0b, #f97316);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s;
}
.btn-login:hover { opacity: .85; }

.user-wrap { position: relative; }

.user-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 8px;
  border: none;
  background: none;
  color: var(--text);
  cursor: pointer;
  transition: background .15s;
}
.user-btn:hover { background: rgba(0, 0, 0, 0.05); }
.user-btn img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.user-btn .uname { font-size: 13px; font-weight: 600; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-btn .chevron { font-size: 10px; color: var(--muted); }

.udd {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 190px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .12);
  display: none;
  z-index: 1000;
}
.udd.open { display: block; }
.udd-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
.udd-head img { width: 34px; height: 34px; border-radius: 50%; }
.udd-head .dn { font-weight: 700; font-size: 13px; color: var(--text); }
.udd-head .un { font-size: 11px; color: var(--muted); }
.udd-sep { height: 1px; background: var(--border); }
.udd-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer; transition: background .1s, color .1s; }
.udd-item i { width: 16px; text-align: center; font-size: 12px; }
.udd-item:hover { background: rgba(0, 0, 0, .04); color: var(--text); }
.udd-item.red { color: #ef4444; }
.udd-item.red:hover { background: rgba(239, 68, 68, .07); }

/* ── MODAL ── */
.modal-bk {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, .45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-bk.open { display: flex; }

.modal-box {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px 24px;
  width: 100%;
  max-width: 360px;
  position: relative;
  box-shadow: 0 12px 48px rgba(0, 0, 0, .15);
}

.modal-x {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 17px;
  cursor: pointer;
  padding: 5px 7px;
  border-radius: 6px;
  line-height: 1;
  transition: color .15s, background .15s;
}
.modal-x:hover { color: var(--text); background: rgba(0, 0, 0, .06); }

.modal-title { font-size: 17px; font-weight: 800; margin-bottom: 4px; color: var(--text); }
.modal-sub   { font-size: 12px; color: var(--muted); margin-bottom: 20px; }

#stepSearch .search-row { display: flex; gap: 8px; }
#stepSearch input {
  flex: 1;
  height: 42px;
  padding: 0 13px;
  border-radius: 9px;
  background: #f5f6fa;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color .15s;
}
#stepSearch input:focus { border-color: #f59e0b; }
#stepSearch input::placeholder { color: #aaa; }

#stepSearch .btn-search {
  height: 42px;
  padding: 0 16px;
  border-radius: 9px;
  border: none;
  background: linear-gradient(90deg, #f59e0b, #f97316);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity .15s;
  display: flex;
  align-items: center;
  gap: 6px;
}
#stepSearch .btn-search:hover    { opacity: .85; }
#stepSearch .btn-search:disabled { opacity: .5; cursor: not-allowed; }

#stepConfirm { display: none; }

.confirm-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #f5f6fa;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 20px;
}
.confirm-card img { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; }
.confirm-card .dn { font-weight: 700; font-size: 15px; color: var(--text); }
.confirm-card .un { font-size: 12px; color: var(--muted); margin-top: 2px; }

.btn-confirm {
  width: 100%;
  height: 44px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(90deg, #f59e0b, #f97316);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity .15s;
  margin-bottom: 10px;
}
.btn-confirm:hover { opacity: .85; }

.btn-back {
  width: 100%;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.btn-back:hover { background: rgba(0, 0, 0, .05); color: var(--text); }

.merr { font-size: 12px; color: #ef4444; margin-top: 8px; min-height: 18px; }

.spin {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, .3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: sp .6s linear infinite;
}
@keyframes sp { to { transform: rotate(360deg); } }

/* ── Cart icon button ── */
.cart-icon-btn {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,.08);
  background: #f9fafb;
  color: #6b7280;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s, border-color .15s;
  flex-shrink: 0;
  margin-right: 6px;
}
.cart-icon-btn:hover { background: rgba(245,158,11,.1); color: #d97706; border-color: rgba(245,158,11,.3); }

/* ── Chat icon button (same style as cart) ── */
.chat-icon-btn {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,.08);
  background: #f9fafb;
  color: #6b7280;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s, border-color .15s;
  flex-shrink: 0;
  margin-right: 6px;
  text-decoration: none;
}
.chat-icon-btn:hover { background: rgba(59,130,246,.1); color: #2563eb; border-color: rgba(59,130,246,.3); }
.chat-icon-dot {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
  border: 2px solid #fff;
}

/* ── Mobile nav: game left + cart/chat right ── */
.mob-nav-games {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
}
.mob-nav-games::-webkit-scrollbar { display: none; }
.mob-nav-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  padding-left: 10px;
}
.mob-nav-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 9px;
  border: 1px solid rgba(0,0,0,.1);
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: all .15s;
  position: relative;
}
.mob-nav-btn:hover { background: rgba(245,158,11,.08); color: #d97706; border-color: rgba(245,158,11,.25); }
.mob-nav-btn.chat:hover { background: rgba(59,130,246,.08); color: #2563eb; border-color: rgba(59,130,246,.25); }
.mob-nav-badge {
  position: absolute;
  top: -5px; right: -5px;
  min-width: 16px; height: 16px;
  background: #ef4444; color: #fff;
  border-radius: 99px; font-size: 9px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px; border: 2px solid #fff;
}

/* ── Balance in dropdown ── */
.udd-balance {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(245,158,11,.06);
  border-top: 1px solid rgba(245,158,11,.1);
  border-bottom: 1px solid rgba(245,158,11,.1);
}
.udd-balance-label { font-size: 11px; color: #9ca3af; }
.udd-balance-amount { font-size: 13px; font-weight: 800; color: #d97706; }

.cart-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 17px;
  height: 17px;
  border-radius: 99px;
  background: #ef4444;
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  border: 2px solid #fff;
}
