/* ═══════════════════════════════════════════════════
   CHOICO THEME – main.css  (global, every page)
═══════════════════════════════════════════════════ */

/* ─── Design Tokens ─────────────────────────── */
:root {
  --bg:          #070b14;
  --bg2:         #0d1221;
  --bg3:         #111827;
  --bg-card:     rgba(17,24,39,.85);
  --border:      rgba(255,255,255,.07);
  --border-h:    rgba(255,255,255,.15);
  --text:        #f0f4ff;
  --text-muted:  #8892a4;
  --text-dim:    #4b5668;

  --vua:         #9b59b6;
  --vua-2:       #6c3483;
  --vua-glow:    rgba(155,89,182,.35);

  --tuong:       #f5a623;
  --tuong-2:     #c87d0e;
  --tuong-glow:  rgba(245,166,35,.35);

  --vay:         #4ecdc4;
  --vay-2:       #1a9e96;
  --vay-glow:    rgba(78,205,196,.35);

  --caro:        #e94560;
  --caro-2:      #b52d45;
  --caro-glow:   rgba(233,69,96,.35);

  --radius:      16px;
  --radius-sm:   10px;
  --shadow:      0 8px 32px rgba(0,0,0,.5);
  --transition:  .3s cubic-bezier(.4,0,.2,1);
}

/* ─── Global Reset ───────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Không reset table/td — các plugin game dùng table để vẽ bàn cờ */
table { margin: revert; padding: revert; }
td, th { padding: revert; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Roboto', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }

/* ─── Focus bàn phím + giảm chuyển động ────────── */
:focus-visible { outline: 2px solid #d8a660; outline-offset: 3px; border-radius: 4px; }
:focus:not(:focus-visible) { outline: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ─── SIDEBAR ─────────────────────────────────── */
body { padding-left: 240px; }

#ch-sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: 240px; z-index: 1000;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow-y: auto; overflow-x: hidden;
  transition: transform var(--transition);
}

/* Brand */
.ch-sb-logo {
  padding: 22px 18px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ch-logo {
  display: flex; align-items: center; gap: 10px;
}
.ch-logo-icon {
  font-size: 1.7rem;
  filter: drop-shadow(0 0 8px rgba(155,89,182,.6));
  animation: logo-pulse 3s ease-in-out infinite;
}
@keyframes logo-pulse {
  0%,100% { filter: drop-shadow(0 0 8px rgba(155,89,182,.6)); }
  50%      { filter: drop-shadow(0 0 16px rgba(155,89,182,1)); }
}
.ch-logo-text {
  font-size: 1.2rem; font-weight: 800;
  color: #efe8da; letter-spacing: -.01em;
}

/* Nav */
.ch-sb-nav {
  flex: 1;
  padding: 12px 10px;
}
.ch-sb-nav ul {
  list-style: none;
  display: flex; flex-direction: column; gap: 2px;
}
.ch-sb-nav li a {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 10px;
  font-size: .9rem; font-weight: 500;
  color: var(--text-muted);
  border-left: 3px solid transparent;
  transition: var(--transition);
}
.ch-sb-nav li a:hover {
  color: var(--text);
  background: rgba(255,255,255,.06);
}
.ch-nav-icon { flex-shrink: 0; transition: var(--transition); }
.ch-sb-nav li.ch-nav-active a {
  color: var(--text);
  background: rgba(216,166,96,.12);
  border-left-color: #d8a660;
}
.ch-sb-nav li.ch-nav-active .ch-nav-icon { filter: none; }

/* Sidebar footer */
.ch-sb-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.ch-sb-btn {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 10px 14px; border-radius: 10px;
  border: none; background: transparent;
  color: var(--text-muted); font-size: .875rem; font-weight: 500;
  font-family: inherit; cursor: pointer;
  transition: var(--transition); text-align: left;
}
.ch-sb-btn:hover { color: var(--text); background: rgba(255,255,255,.06); }
.ch-sb-btn.active { color: var(--vua); }

/* Mobile overlay */
.ch-sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.6); z-index: 999;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.ch-sidebar-overlay.open { display: block; }

/* Nhóm menu */
.ch-nav-head {
  padding: 14px 14px 6px;
  font-size: .78rem; font-weight: 600; color: var(--text-muted);
}

/* ─── TÀI KHOẢN (menu trái + thanh trên điện thoại) ─── */
.ch-sb-account {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ch-acc-hint {
  font-size: .8rem; line-height: 1.45; color: var(--text-muted);
  margin-bottom: 10px;
}
.ch-acc-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ch-btn-login, .ch-btn-reg {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 40px; padding: 0 12px; border-radius: 10px;
  font-family: inherit; font-size: .875rem; font-weight: 700; white-space: nowrap;
  border: 1px solid #d8a660; transition: background-color .2s, color .2s, border-color .2s;
}
.ch-btn-login { background: transparent; color: #ecc98f; }
.ch-btn-login:hover { background: rgba(216,166,96,.14); color: #f6dcae; }
.ch-btn-reg { background: #d8a660; color: #22170b; }
.ch-btn-reg:hover { background: #e7bb7b; border-color: #e7bb7b; }

.ch-acc-user, .ch-acc-compact .ch-acc-user { display: none; }
html.ch-has-player .ch-acc-guest { display: none; }
html.ch-has-player .ch-acc .ch-acc-user { display: block; }
html.ch-has-player .ch-acc-compact .ch-acc-user { display: inline-flex; }
.ch-acc-me {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px;
  background: rgba(216,166,96,.08); border: 1px solid rgba(216,166,96,.22);
  transition: background-color .2s;
}
.ch-acc-me:hover { background: rgba(216,166,96,.16); }
.ch-acc-av {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: #d8a660; color: #22170b; font-weight: 800; font-size: 1rem;
}
.ch-acc-txt { display: flex; flex-direction: column; min-width: 0; }
.ch-acc-name {
  font-size: .92rem; font-weight: 700; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ch-acc-pts { font-size: .78rem; color: #e7bb7b; }
.ch-acc-out {
  display: block; margin: 6px 0 0 auto; padding: 6px 4px;
  border: 0; background: none; color: var(--text-muted);
  font-size: .8rem; font-family: inherit;
}
.ch-acc-out:hover { color: var(--text); text-decoration: underline; }

/* Màn PC thấp: gọn menu để thấy đủ các mục không cần cuộn */
@media (min-width: 769px) and (max-height: 820px) {
  .ch-sb-logo { padding: 16px 18px 14px; }
  .ch-acc-hint { display: none; }
  .ch-sb-account { padding: 12px 14px; }
  .ch-sb-nav { padding: 8px 10px; }
  .ch-sb-nav li a { padding: 8px 14px; }
  .ch-nav-head { padding: 8px 14px 3px; }
}

/* ─── THANH TRÊN + MENU TRƯỢT (điện thoại) ─── */
.ch-topbar, .ch-sb-close { display: none; }
.ch-hamburger {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 14px 0 12px; border-radius: 12px;
  border: 1px solid rgba(216,166,96,.5);
  background: rgba(216,166,96,.12); color: #efe8da;
  font-size: .9rem; font-weight: 700;
  transition: background-color .2s;
}
.ch-hamburger:hover, .ch-hamburger[aria-expanded="true"] { background: rgba(216,166,96,.24); }
.ch-hb-lines { display: inline-flex; flex-direction: column; gap: 4px; }
.ch-hb-lines span {
  display: block; width: 18px; height: 2px; border-radius: 2px; background: #d8a660;
}
.ch-sb-close {
  align-items: center; justify-content: center;
  width: 44px; height: 44px; margin-right: -6px; border-radius: 10px;
  border: 1px solid var(--border-h); background: rgba(255,255,255,.04); color: var(--text);
}
.ch-sb-close:hover { background: rgba(255,255,255,.1); }

/* ─── PAGE WRAPPER ────────────────────────────── */
.choico-page-content {
  position: relative; z-index: 1;
  min-height: 100vh;
  background: var(--bg);
}

/* ─── FOOTER ──────────────────────────────────── */
#ch-footer {
  position: relative; z-index: 1;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 64px 24px 0;
}
.ch-footer-inner {
  max-width: 1100px; margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 48px;
  padding-bottom: 48px;
}
.ch-footer-brand .ch-logo { margin-bottom: 16px; }
.ch-footer-brand p {
  color: var(--text-muted); font-size: .88rem; line-height: 1.7;
}
.ch-footer-links .ch-footer-title {
  font-size: .9rem; font-weight: 700;
  color: var(--text-muted); margin-bottom: 16px;
}
.ch-footer-links a {
  display: block; color: var(--text-muted);
  font-size: .9rem; margin-bottom: 10px;
  transition: var(--transition);
}
.ch-footer-links a:hover { color: var(--text); padding-left: 4px; }

.ch-footer-bottom {
  border-top: 1px solid var(--border);
  padding: 20px 0;
  text-align: center;
  color: var(--text-muted);
  font-size: .82rem;
}

/* ─── SCROLL-TO-TOP ───────────────────────────── */
.ch-scroll-top {
  position: fixed; bottom: 28px; right: 28px; z-index: 999;
  width: 44px; height: 44px; border-radius: 12px;
  background: rgba(155,89,182,.25); border: 1px solid rgba(155,89,182,.45);
  color: #fff; font-size: 1.1rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transform: translateY(12px); pointer-events: none;
  transition: var(--transition);
  backdrop-filter: blur(10px);
}
.ch-scroll-top.visible {
  opacity: 1; transform: none; pointer-events: all;
}
.ch-scroll-top:hover {
  background: rgba(155,89,182,.55);
  box-shadow: 0 4px 20px var(--vua-glow);
}

/* ─── TOAST ───────────────────────────────────── */
.ch-toast {
  position: fixed; bottom: 88px; left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: rgba(17,24,39,.97); border: 1px solid var(--border-h);
  color: var(--text); padding: 12px 24px; border-radius: 10px;
  font-size: .9rem; font-weight: 500; z-index: 1070; /* --cc-z-toast */
  opacity: 0; pointer-events: none; transition: all .3s ease;
  backdrop-filter: blur(20px); white-space: nowrap;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
}
.ch-toast.show {
  opacity: 1; transform: translateX(-50%) translateY(0);
}
.ch-toast-error   { border-color: rgba(231,76,60,.5);  color: #ff8a80; }
.ch-toast-success { border-color: rgba(39,174,96,.5);  color: #69f0ae; }

/* ─── RESPONSIVE ──────────────────────────────── */
@media (max-width: 768px) {
  body { padding-left: 0; padding-top: 60px; }
  .ch-topbar {
    display: flex; align-items: center; gap: 12px;
    position: fixed; top: 0; left: 0; right: 0; z-index: 1020; /* --cc-z-sticky */
    height: 60px; padding: 0 12px;
    background: rgba(13,18,33,.96); border-bottom: 1px solid var(--border-h);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  }
  .ch-topbar .ch-logo { margin-right: auto; gap: 8px; }
  .ch-topbar .ch-logo-icon { font-size: 1.4rem; }
  .ch-topbar .ch-logo-text { font-size: 1.1rem; }
  .ch-acc-compact { display: flex; align-items: center; }
  .ch-acc-compact .ch-btn-login { min-height: 44px; padding: 0 16px; background: #d8a660; color: #22170b; }
  .ch-acc-compact .ch-acc-av { width: 40px; height: 40px; box-shadow: 0 0 0 2px rgba(216,166,96,.35); }

  /* Menu trượt nằm trên thanh trên, dưới hộp đăng nhập (1040) */
  .ch-sidebar-overlay { z-index: 1030; }
  #ch-sidebar {
    z-index: 1035; width: min(86vw, 320px);
    transform: translateX(-100%); visibility: hidden;
    transition: transform var(--transition), visibility 0s linear .3s;
  }
  #ch-sidebar.open {
    transform: translateX(0); visibility: visible; box-shadow: 8px 0 32px rgba(0,0,0,.6);
    transition: transform var(--transition), visibility 0s;
  }
  .ch-sb-logo { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px 8px 18px; }
  .ch-sb-close { display: inline-flex; }
  .ch-sb-account { padding: 14px 16px; }
  .ch-btn-login, .ch-btn-reg { min-height: 46px; font-size: .95rem; }
  .ch-sb-nav li a { min-height: 48px; font-size: 1rem; padding: 10px 14px; }
  .ch-nav-icon { width: 20px; height: 20px; }
  body.ch-menu-open { overflow: hidden; }

  .ch-footer-inner {
    grid-template-columns: 1fr;
    gap: 32px;
  }
  .ch-footer-links { display: grid; grid-template-columns: 1fr 1fr; gap: 0 32px; }
  .ch-footer-links .ch-footer-title { grid-column: 1/-1; }
}

/* ─── Truy cập: link bỏ qua + chữ chỉ dành cho trình đọc màn hình ─── */
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; top: 8px; left: 8px; z-index: 1070;
  display: inline-flex; align-items: center; min-height: 44px;
  padding: 10px 16px; border-radius: 8px;
  background: #d8a660; color: #22170b; font-weight: 700;
  transform: translateY(-150%); transition: transform .15s ease;
}
.skip-link:focus { transform: none; }

/* ─── Vùng chạm tối thiểu 44px trên màn hình cảm ứng ─── */
@media (max-width: 768px), (pointer: coarse) {
  .ch-footer-links a { display: flex; align-items: center; min-height: 44px; margin-bottom: 0; }
  .ch-logo { min-height: 44px; display: inline-flex; align-items: center; }
  .ch-footer-bottom { padding: 20px 0 28px; }
}
