/* ===== Design tokens ===== */
:root {
  --bg: #f4f1ea;
  --panel: #fffdf8;
  --panel-2: #efe9dd;
  --ink: #20242b;
  --muted: #6b6f78;
  --line: #d9d2c4;
  --accent: #b8232c;
  --accent-soft: #f2dada;
  --good: #1f7a4d;
  --good-bg: #dff0e6;
  --avoid: #b8232c;
  --avoid-bg: #f6dede;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08);
  /* unit colors */
  --ky: #2563b8;
  --cung: #1f7a4d;
  --thuong: #b8232c;
  --khien: #8a6d1f;
  /* faction colors: Ngụy xanh đậm, Thục xanh lá, Ngô đỏ, Quần vàng */
  --f-nguy: #1f3a93;
  --f-thuc: #1f7a4d;
  --f-ngo: #b8232c;
  --f-quan: #c9962a;
  --f-honhop: #7349a8;
}
:root[data-theme="dark"] {
  --bg: #14161b;
  --panel: #1d2027;
  --panel-2: #23272f;
  --ink: #e7e3da;
  --muted: #9aa0ab;
  --line: #333944;
  --accent: #e0555d;
  --accent-soft: #3a2326;
  --good: #5fce95;
  --good-bg: #1c3328;
  --avoid: #e0555d;
  --avoid-bg: #362325;
  --shadow: 0 1px 3px rgba(0, 0, 0, .35);
  --ky: #6aa6ff;
  --cung: #5fce95;
  --thuong: #e0555d;
  --khien: #d6b85a;
  --f-nguy: #4f74d6;
  --f-thuc: #5fce95;
  --f-ngo: #e0555d;
  --f-quan: #e0b94e;
  --f-honhop: #a884e0;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}

/* ===== Header ===== */
.top-header {
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 50;
}
.site-header {
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; padding: .7rem 1.2rem;
  background: var(--panel); border-bottom: 2px solid var(--accent);
}
.brand { display: flex; align-items: center; gap: .7rem; }
.site-header h1 { font-size: 1.15rem; margin: 0; }
.tagline { margin: 0; font-size: .78rem; color: var(--muted); }
.header-actions { display: flex; align-items: center; gap: .8rem; }
.stats { font-size: .82rem; color: var(--muted); white-space: nowrap; }
.icon-btn { background: none; border: 1px solid var(--line); border-radius: 8px; padding: .35rem .55rem; cursor: pointer; font-size: 1rem; color: var(--ink); }

/* ===== Section nav ===== */
.section-nav {
  display: flex; gap: .3rem; padding: .5rem 1.2rem 0; background: var(--panel);
  flex-wrap: wrap;
}
.section-menu-toggle { display: none; }
.section-menu-items { display: flex; gap: .3rem; flex-wrap: wrap; }
.nav-tab {
  background: none; border: none; border-bottom: 3px solid transparent;
  padding: .5rem .9rem; font-size: .92rem; cursor: pointer; color: var(--muted);
  border-radius: 6px 6px 0 0;
}
.nav-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.disclaimer { font-size: .76rem; color: var(--muted); padding: .5rem 1.2rem 0; margin: 0; font-style: italic; }

/* ===== Layout (1 cột, filter inline trong từng tab) ===== */
.layout { padding: 1rem 1.2rem 3rem; }
.content { min-width: 0; }

/* ===== Filter inline (dùng chung Team PK / Đô Úy / Meta cũ) ===== */
.filter-collapse-toggle { display: none; }
.filter-bar { display: flex; gap: .5rem; margin-bottom: .8rem; }
/* Ô tìm kiếm: focus ring rõ, chuyển động mượt. */
.search {
  flex: 1; min-width: 0; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 9px;
  background: var(--bg); color: var(--ink); font-size: .85rem;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.search::placeholder { color: var(--muted); }
.search:hover { border-color: var(--muted); }
.search:focus-visible, .combo-input:focus-visible {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.clear-btn {
  display: inline-flex; align-items: center; gap: .4rem; line-height: 1;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--muted); border-radius: 9px;
  padding: .56rem .85rem; cursor: pointer; font-size: .8rem; font-weight: 600; white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
/* Icon ✕ trong vòng tròn nhỏ làm affordance "xóa". */
.clear-btn::before {
  content: "✕"; display: inline-flex; align-items: center; justify-content: center;
  width: 1.05em; height: 1.05em; border-radius: 50%; font-size: .82em; font-weight: 700;
  background: var(--line); color: var(--panel); transition: background .15s ease, color .15s ease;
}
.clear-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.clear-btn:hover::before { background: var(--accent); color: #fff; }
.clear-btn:active { transform: translateY(1px); }
.clear-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); border-color: var(--accent); }
/* Stats dạng pill nhẹ ở cuối hàng. */
.team-filter-bar .stats {
  margin-left: auto; padding: .3rem .6rem; border-radius: 999px;
  background: var(--panel-2); color: var(--muted); font-weight: 600;
}
.fgroup { margin-bottom: .9rem; }
.fgroup.combo { position: relative; }
.flabel { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: .4rem; font-weight: 700; }
.chip-row { display: flex; flex-wrap: wrap; gap: .35rem; }
/* Chip lọc: hover nâng nhẹ, focus ring, selected có chiều sâu. */
.fchip {
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 999px;
  padding: .3rem .7rem; font-size: .78rem; font-weight: 500; cursor: pointer; line-height: 1.2;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .12s ease, box-shadow .15s ease;
}
.fchip:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }
.fchip:active { transform: translateY(0) scale(.97); }
.fchip:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); border-color: var(--accent); }
.fchip.on { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 2px 6px rgba(184, 35, 44, .28); }
.fchip.on:hover { background: var(--accent); transform: translateY(-1px); }
/* Chip Phe: chấm màu trước nhãn + nền màu phe khi chọn */
.fchip[class*="f-"]::before { content: ""; display: inline-block; width: .55em; height: .55em; border-radius: 50%; margin-right: .35rem; vertical-align: baseline; }
.fchip.f-nguy::before { background: var(--f-nguy); }
.fchip.f-thuc::before { background: var(--f-thuc); }
.fchip.f-ngo::before { background: var(--f-ngo); }
.fchip.f-quan::before { background: var(--f-quan); }
.fchip.f-honhop::before { background: var(--f-honhop); }
.fchip.f-nguy.on { background: var(--f-nguy); border-color: transparent; color: #fff; }
.fchip.f-thuc.on { background: var(--f-thuc); border-color: transparent; color: #fff; }
.fchip.f-ngo.on { background: var(--f-ngo); border-color: transparent; color: #fff; }
.fchip.f-quan.on { background: var(--f-quan); border-color: transparent; color: #3a2c00; }
.fchip.f-honhop.on { background: var(--f-honhop); border-color: transparent; color: #fff; }
.fchip.on[class*="f-"]::before { background: #fff; }
.fchip.f-quan.on::before { background: #3a2c00; }
.combo-input {
  width: 100%; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 9px;
  background: var(--bg); color: var(--ink); font-size: .82rem;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.combo-input:hover { border-color: var(--muted); }
/* Dropdown autocomplete nổi như popover, không đẩy layout. */
.combo-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30;
  display: flex; flex-direction: column; gap: 1px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .14); padding: .3rem; max-height: 280px; overflow-y: auto;
}
.combo-list:empty { display: none; }
.combo-item {
  text-align: left; border: none; background: transparent; color: var(--ink);
  padding: .42rem .55rem; cursor: pointer; font-size: .8rem; border-radius: 6px;
  transition: background .12s ease, color .12s ease;
}
.combo-item:hover { background: var(--accent-soft); color: var(--accent); }
.combo-item:focus-visible { outline: none; background: var(--accent-soft); color: var(--accent); }
.combo-selected { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .45rem; }
.sel-tag {
  display: inline-flex; align-items: center; gap: .15rem; background: var(--accent); color: #fff; border: none;
  border-radius: 999px; padding: .25rem .6rem; font-size: .76rem; font-weight: 500; cursor: pointer;
  transition: background .15s ease, transform .12s ease;
}
.sel-tag:hover { filter: brightness(.92); transform: translateY(-1px); }
.sel-tag:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

/* ===== Team grid ===== */
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: .9rem; }
.team-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; box-shadow: var(--shadow); transition: transform .12s ease, box-shadow .12s ease; }
.team-card:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0, 0, 0, .12); }
.team-card.dim { opacity: .82; }
.team-name { display: block; width: 100%; text-align: left; background: none; border: none; cursor: pointer; padding: 0 0 .4rem; margin-bottom: .5rem; color: var(--accent); font-size: 1rem; font-weight: 700; letter-spacing: .01em; }
.team-name:hover { text-decoration: underline; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; margin-bottom: .6rem; padding-bottom: .5rem; border-bottom: 1px dashed var(--line); }
.units { display: flex; gap: .25rem; flex-wrap: wrap; }
.head-right { display: flex; gap: .3rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

.badge { font-size: .72rem; padding: .15rem .5rem; border-radius: 6px; font-weight: 600; white-space: nowrap; }
.badge.unit { color: #fff; }
.badge.unit.small { font-size: .62rem; padding: .05rem .3rem; }
.u-ky { background: var(--ky); } .u-cung { background: var(--cung); } .u-thuong { background: var(--thuong); } .u-khien { background: var(--khien); }
.badge.stars { background: #f5c542; color: #5a4500; }
/* Tier team (tham khảo, multi-source): T0 mạnh -> T3 nhạt; half-tier dùng class t-05/t-15 */
.badge.tier { color: #fff; cursor: help; letter-spacing: .02em; }
.badge.tier.t-0 { background: #c0392b; }
.badge.tier.t-05 { background: #d35400; }
.badge.tier.t-1 { background: #e67e22; }
.badge.tier.t-15 { background: #d4a017; color: #3a2c00; }
.badge.tier.t-2 { background: #2980b9; }
.badge.tier.t-3 { background: var(--muted); }
.badge.faction { background: var(--panel-2); color: var(--ink); border: 1px solid var(--line); }
/* Phe: tô màu nhãn + viền trái card để quét nhanh */
.badge.faction.f-nguy { background: var(--f-nguy); color: #fff; border-color: transparent; }
.badge.faction.f-thuc { background: var(--f-thuc); color: #fff; border-color: transparent; }
.badge.faction.f-ngo { background: var(--f-ngo); color: #fff; border-color: transparent; }
.badge.faction.f-quan { background: var(--f-quan); color: #3a2c00; border-color: transparent; }
.badge.faction.f-honhop { background: var(--f-honhop); color: #fff; border-color: transparent; }
.team-card.fa-nguy { border-left: 4px solid var(--f-nguy); }
.team-card.fa-thuc { border-left: 4px solid var(--f-thuc); }
.team-card.fa-ngo { border-left: 4px solid var(--f-ngo); }
.team-card.fa-quan { border-left: 4px solid var(--f-quan); }
.team-card.fa-honhop { border-left: 4px solid var(--f-honhop); }
.badge.status { border: 1px solid var(--line); }
.status-out-meta { background: var(--panel-2); color: var(--muted); }
.status-youtuber-untested { background: #efe0fb; color: #6b2fb3; }
.status-situational { background: #fde9d6; color: #9a5a1a; }
.badge.recommend { background: #1e8e4e; color: #fff; letter-spacing: .01em; }

.heroes { display: flex; flex-direction: column; gap: .5rem; }
.hero { padding: .35rem .45rem; background: var(--bg); border-radius: 8px; }
.hero-name { font-size: .92rem; margin-bottom: .2rem; display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
.hn { font-weight: 700; }
.pre { font-size: .6rem; font-weight: 700; padding: .05rem .25rem; border-radius: 4px; color: #fff; }
.pre.sp { background: var(--accent); } .pre.co { background: var(--khien); }
.variant { font-size: .74rem; color: var(--muted); }
.line { display: flex; flex-wrap: wrap; gap: .25rem .15rem; align-items: center; margin-top: .15rem; }
.vg { display: inline-flex; align-items: center; gap: .1rem; }
.alt-sep { color: var(--muted); font-size: .7rem; }
.tag { border: none; cursor: pointer; font-size: .76rem; padding: .12rem .4rem; border-radius: 5px; }
.t-tactic { background: var(--accent-soft); color: var(--accent); }
.t-book { background: var(--panel-2); color: var(--muted); font-size: .72rem; }
.tag.alt { opacity: .75; font-style: italic; }

.counters { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .6rem; padding-top: .5rem; border-top: 1px dashed var(--line); }
.chip { border: none; cursor: pointer; font-size: .73rem; padding: .15rem .45rem; border-radius: 999px; }
.chip.good { background: var(--good-bg); color: var(--good); }
.chip.avoid { background: var(--avoid-bg); color: var(--avoid); }
.notes { margin-top: .5rem; font-size: .76rem; color: var(--muted); font-style: italic; }
.empty, .error { color: var(--muted); padding: 2rem; text-align: center; grid-column: 1 / -1; }
.error { color: var(--accent); }

/* ===== Sections ===== */
.section { display: none; }
.section.active { display: block; }

/* Coexist — card lồng, tái dùng kiểu .hero + tag */
.coexist-group { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1.2rem; }
.coexist-group > h3 { margin: 0 0 .5rem; font-size: 1rem; color: var(--accent); }
.coexist-teams { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .8rem; }
.coexist-subteam { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: .6rem; }
.coexist-subteam-title { margin: 0 0 .5rem; font-size: .88rem; padding-bottom: .35rem; border-bottom: 1px dashed var(--line); }
/* tag chiến pháp/binh thư ở Cùng Tồn chỉ hiển thị, không bấm */
.coexist-subteam .tag { cursor: default; }
.ct-meta { display: flex; flex-wrap: wrap; gap: .15rem .6rem; margin-top: .25rem; font-size: .72rem; color: var(--muted); }
.ct-meta-item b { color: var(--ink); font-weight: 600; }
/* Tổng quan combo — thu gọn được */
.coexist-summary-box { margin: 0 0 .8rem; font-size: .82rem; }
.coexist-summary-box > summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.coexist-summary { margin: .4rem 0 0; color: var(--muted); line-height: 1.5; }
.muted { color: var(--muted); } .stat { color: var(--ky); } .advisor { color: var(--khien); }

/* Khaihoang */
.mines { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.mine { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem; }
.mine h3 { margin: 0 0 .6rem; color: var(--accent); }
.enemies { display: flex; flex-direction: column; gap: .35rem; }
.enemy { display: flex; justify-content: space-between; align-items: center; padding: .3rem .5rem; background: var(--bg); border-radius: 6px; border-left: 3px solid var(--line); font-size: .85rem; }
.enemy.u-ky { border-left-color: var(--ky); } .enemy.u-cung { border-left-color: var(--cung); }
.enemy.u-thuong { border-left-color: var(--thuong); } .enemy.u-khien { border-left-color: var(--khien); }

/* Khai hoang — đội hình đề xuất (tái dùng kiểu card Team PK) */
.kh-block { margin-bottom: 1.6rem; }
.kh-section-title { font-size: 1rem; color: var(--accent); margin: 0 0 .8rem; padding-bottom: .35rem; border-bottom: 2px solid var(--line); }
.kh-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.kh-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; box-shadow: var(--shadow); transition: transform .12s ease, box-shadow .12s ease; }
.kh-card:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0, 0, 0, .12); }
.kh-title { margin: 0; font-size: .9rem; text-align: right; }
/* Nhãn Trước/Sau đứng đầu mỗi dòng chiến pháp. */
.kh-line .kh-label { font-size: .66rem; font-weight: 700; color: var(--muted); text-transform: uppercase; min-width: 2.6rem; }
.kh-note { font-size: .73rem; color: var(--muted); font-style: italic; margin-top: .15rem; }
/* Tag chiến pháp ở khai hoang chỉ để hiển thị, không bấm. */
.kh-card .tag, .kh-tf .tag { cursor: default; }
.kh-transforms { margin-top: .6rem; padding-top: .5rem; border-top: 1px dashed var(--line); }
.kh-tf-label { display: block; font-size: .73rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: .35rem; }
.kh-tf { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; font-size: .8rem; margin-bottom: .2rem; }

/* Footer */
.site-footer { text-align: center; padding: 1.5rem; color: var(--muted); font-size: .78rem; border-top: 1px solid var(--line); }
.site-footer .credit { margin-top: .4rem; }
.site-footer .credit strong { color: var(--text); }

/* ===== Tra cứu chiến pháp ===== */
.tac-toolbar { position: sticky; top: 96px; z-index: 5; background: var(--bg); padding: .4rem 0 .6rem; display: flex; flex-direction: column; gap: .5rem; }
.tac-search { width: 100%; padding: .55rem .8rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink); font-size: .95rem; }
.tac-filter-row { display: flex; flex-wrap: wrap; gap: .8rem; }
.tac-chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.tac-count { font-size: .78rem; color: var(--muted); }
.tac-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .7rem; margin-top: .4rem; }
.tac-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); padding: .65rem .75rem; display: flex; flex-direction: column; gap: .35rem; }
.tac-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.tac-viet { font-weight: 700; font-size: .98rem; color: var(--ink); }
.tac-q { font-weight: 700; font-size: .72rem; padding: .08rem .4rem; border-radius: 999px; color: #fff; }
.tac-q.q-S { background: var(--accent); }
.tac-q.q-A { background: var(--f-nguy); }
.tac-q.q-B { background: var(--muted); }
.tac-sub { display: flex; gap: .5rem; flex-wrap: wrap; font-size: .8rem; color: var(--muted); }
.tac-cn { font-weight: 600; }
.tac-meta { display: flex; flex-wrap: wrap; gap: .3rem; }
.tac-type { font-size: .72rem; padding: .08rem .45rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.tac-troop { font-size: .72rem; padding: .08rem .45rem; border-radius: 999px; background: var(--panel-2); color: var(--ink); }
.tac-descs { display: grid; gap: .35rem; }
.tac-desc { margin: 0; font-size: .82rem; line-height: 1.45; color: var(--ink); }
.tac-desc-zh { color: var(--muted); }
.tac-desc-label { color: var(--accent); font-size: .75rem; }
.tac-desc.pending { color: var(--muted); font-style: italic; }

/* ===== Theo dõi chiêu mộ ===== */
.rt-shell { display: grid; gap: .85rem; }
.rt-section {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .85rem 1rem; box-shadow: var(--shadow);
}
.rt-section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .8rem; margin-bottom: .7rem; }
.rt-section h2 { margin: 0; font-size: 1rem; color: var(--accent); }
.rt-sub { color: var(--muted); font-size: .78rem; margin: .12rem 0 0; }
.rt-account-bar { display: flex; justify-content: space-between; align-items: center; gap: .8rem; }
.rt-account-main { display: flex; align-items: center; gap: .45rem; min-width: 220px; }
.rt-kicker { font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.rt-select,
.rt-form input,
.rt-form select {
  min-height: 2.35rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink); padding: .42rem .55rem; font: inherit;
}
.rt-actions { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; justify-content: flex-end; }
.rt-btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 2.25rem;
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2);
  color: var(--ink); padding: .42rem .7rem; cursor: pointer; font-size: .82rem; font-weight: 650;
}
.rt-btn:hover { border-color: var(--accent); color: var(--accent); }
.rt-btn:disabled { opacity: .55; cursor: not-allowed; }
.rt-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.rt-primary:hover { color: #fff; filter: brightness(1.03); }
.rt-btn-small { min-height: 2rem; padding: .3rem .55rem; font-size: .76rem; }
.rt-file { display: none; }
.rt-import { position: relative; overflow: hidden; }
.rt-message {
  margin: 0; padding: .55rem .75rem; border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 8px; background: var(--panel); color: var(--ink); font-size: .84rem;
}
.rt-pity {
  display: inline-flex; align-items: baseline; gap: .35rem; flex-wrap: wrap;
  background: var(--panel-2); border-radius: 8px; padding: .35rem .55rem; min-width: 9rem;
}
.rt-pity-label { font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.rt-pity strong { color: var(--accent); font-size: 1rem; }
.rt-warning { color: var(--avoid); font-size: .75rem; font-weight: 700; }
.rt-pity.warn { border: 1px solid var(--avoid); }
.rt-daily-meta { color: var(--muted); font-size: .82rem; margin: -.25rem 0 .55rem; }
.rt-slot-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .55rem; }
.rt-slot {
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
  padding: .55rem; display: flex; flex-direction: column; gap: .55rem; min-height: 7rem;
}
.rt-slot-main { display: flex; flex-direction: column; gap: .16rem; }
.rt-slot-label { font-weight: 700; }
.rt-slot-status { font-size: .76rem; color: var(--muted); }
.rt-slot-miss { border-left: 3px solid var(--muted); }
.rt-slot-fiveStar { border-left: 3px solid var(--accent); background: var(--accent-soft); }
.rt-slot-actions { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: auto; }
.rt-limited-list { display: grid; gap: .45rem; }
.rt-limited {
  border: 1px solid var(--line); border-radius: 8px; padding: .55rem .65rem;
  display: flex; align-items: center; justify-content: space-between; gap: .7rem; background: var(--bg);
}
.rt-limited-main { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.rt-empty { margin: 0; color: var(--muted); font-size: .84rem; }
.rt-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .65rem; align-items: end; }
.rt-form label { display: flex; flex-direction: column; gap: .25rem; font-size: .78rem; color: var(--muted); font-weight: 700; }
.rt-form label span { color: var(--muted); }
.rt-form-wide { grid-column: span 2; }
.rt-history { display: grid; gap: .45rem; }
.rt-history-item { border: 1px solid var(--line); border-radius: 8px; background: var(--bg); padding: .55rem .65rem; }
.rt-history-meta { color: var(--muted); font-size: .76rem; margin-bottom: .2rem; }
.rt-history-hero { display: flex; flex-wrap: wrap; gap: .45rem; align-items: baseline; }
.rt-note { margin: .35rem 0 0; color: var(--muted); font-size: .8rem; font-style: italic; }

/* ===== Filter bar inline + section intro (dùng chung 3 tab team) ===== */
.team-filter-bar {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: .85rem 1rem; margin-bottom: 1.1rem; box-shadow: var(--shadow);
}
.team-filter-bar .filter-bar { margin-bottom: 0; align-items: center; }
/* Phân cách hàng search với vùng nhóm lọc. */
.team-filters { display: flex; flex-wrap: wrap; gap: .75rem 1.6rem; margin-top: .85rem; padding-top: .85rem; border-top: 1px solid var(--line); }
.team-filters .fgroup { margin-bottom: 0; flex: 0 1 auto; min-width: 150px; }
.team-filters .fgroup.combo { flex: 1 1 200px; max-width: 280px; }
/* Desktop: bỏ qua trạng thái thu gọn (chỉ áp dụng ở mobile). */
.team-filters.collapsed { display: flex; }
.fchip.recommend { border-color: var(--good); color: var(--good); }
.fchip.recommend:hover { background: var(--good-bg); border-color: var(--good); }
.fchip.recommend.on { background: var(--good); border-color: var(--good); color: #fff; box-shadow: 0 2px 6px rgba(31, 122, 77, .28); }

.section-intro { margin: .2rem 0 .8rem; }
.section-intro-title { margin: 0 0 .2rem; font-size: 1.1rem; color: var(--accent); }
.section-intro-sub { margin: 0; font-size: .82rem; color: var(--muted); }

/* ===== Tra cứu tướng ===== */
.fgroup-inline { display: flex; flex-direction: column; gap: .25rem; }
.flabel-inline { font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
.hero-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .7rem; margin-top: .4rem; }
.hero-card { display: flex; gap: .6rem; align-items: flex-start; text-align: left; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); padding: .55rem .65rem; cursor: pointer; transition: transform .12s ease, box-shadow .12s ease; }
.hero-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0, 0, 0, .12); border-color: var(--accent); }
.hc-icon { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; background: var(--panel-2); flex-shrink: 0; }
.hc-body { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.hc-name { font-weight: 700; font-size: .9rem; color: var(--ink); }
.hc-badges { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; }
.badge.role { background: var(--accent-soft); color: var(--accent); }
.hc-apt { display: flex; flex-wrap: wrap; gap: .2rem; }
.apt { display: inline-flex; gap: .2rem; font-size: .68rem; padding: .06rem .4rem; border-radius: 999px; background: var(--panel-2); color: var(--ink); }
.apt-s { background: var(--accent); color: #fff; }
.apt-a { background: var(--f-nguy); color: #fff; }
.apt-troop { font-weight: 600; }

/* Modal chi tiết tướng */
.hero-overlay { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .5); display: flex; align-items: flex-start; justify-content: center; padding: 4vh 1rem; overflow-y: auto; }
.hero-overlay-close { position: absolute; top: 1rem; right: 1rem; width: 2.2rem; height: 2.2rem; border-radius: 50%; border: none; background: var(--panel); color: var(--ink); font-size: 1.1rem; cursor: pointer; box-shadow: var(--shadow); }
.hero-modal { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 30px rgba(0, 0, 0, .3); padding: 1rem 1.1rem; max-width: 540px; width: 100%; display: flex; flex-direction: column; gap: .85rem; }
.hero-modal-head { display: flex; gap: .8rem; align-items: center; }
.hero-modal-icon { width: 72px; height: 72px; border-radius: 10px; object-fit: cover; background: var(--panel-2); flex-shrink: 0; }
.hero-modal-id { display: flex; flex-direction: column; gap: .3rem; }
.hero-modal-name { margin: 0; font-size: 1.2rem; display: flex; gap: .4rem; align-items: center; }
.hero-modal-badges { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.hero-modal-cn { font-size: .8rem; color: var(--muted); }
.hero-stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: .35rem; }
.hero-stat { display: flex; flex-direction: column; align-items: center; background: var(--panel-2); border-radius: 6px; padding: .3rem .15rem; }
.hs-label { font-size: .66rem; color: var(--muted); }
.hs-val { font-weight: 700; font-size: .92rem; }
.hero-apt { display: flex; flex-wrap: wrap; gap: .3rem; }
.hero-apt .apt { font-size: .72rem; padding: .12rem .45rem; }
.hero-tactics { display: flex; flex-direction: column; gap: .6rem; }
.hero-tactic { border: 1px solid var(--line); border-radius: 8px; padding: .55rem .65rem; }
.ht-head { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; margin-bottom: .3rem; }
.ht-slot { font-size: .68rem; font-weight: 700; text-transform: uppercase; color: var(--accent); }
.ht-name { font-weight: 700; font-size: .9rem; }
.ht-type { font-size: .7rem; padding: .06rem .4rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.ht-effect { margin: 0; font-size: .82rem; line-height: 1.45; color: var(--ink); }
.ht-effect.pending { color: var(--muted); font-style: italic; }

/* ===== Soi đội từ ảnh ===== */
.ana-disclaimer { font-size: .8rem; color: var(--muted); background: var(--panel-2); border-radius: var(--radius); padding: .5rem .7rem; margin: 0 0 .8rem; }
.ana-setup { padding: 1.2rem; border: 1px dashed var(--line); border-radius: var(--radius); text-align: center; color: var(--muted); }
.ana-drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 1.4rem; text-align: center; color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s; }
.ana-drop:hover, .ana-drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.ana-file { display: none; }
.ana-preview { display: none; max-width: 100%; max-height: 260px; margin: .7rem 0; border-radius: var(--radius); border: 1px solid var(--line); }
.ana-preview.on { display: block; }
.ana-turnstile { margin: .6rem 0; }
.ana-btn { background: var(--accent); color: #fff; border: none; border-radius: var(--radius); padding: .55rem 1.1rem; font-size: .95rem; font-weight: 600; cursor: pointer; }
.ana-btn:disabled { opacity: .5; cursor: not-allowed; }
.ana-status { font-size: .85rem; margin: .5rem 0; }
.ana-status.err { color: var(--avoid); }
.ana-results { margin-top: 1rem; }
.ana-rh { font-size: .95rem; margin: 1rem 0 .5rem; }
.ana-heroes { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .6rem; }
.ana-hero { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: .55rem .7rem; }
.ana-hero-head { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin-bottom: .35rem; }
.ana-hero-name { font-weight: 700; }
.ana-stat { font-size: .72rem; padding: .06rem .4rem; border-radius: 999px; background: var(--f-nguy); color: #fff; }
.ana-flag { font-size: .7rem; color: var(--avoid); }
.ana-hero-icon { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex: none; }
.ana-tactics { display: flex; flex-wrap: wrap; gap: .3rem; }
.ana-tac { font-size: .76rem; padding: .08rem .45rem; border-radius: 999px; background: var(--panel-2); }
.ana-tac.unsure { border: 1px dashed var(--avoid); color: var(--avoid); }
/* Binh thư (dòng vàng) — phân biệt với chiến pháp bằng viền vàng nhạt. */
.ana-books { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .3rem; }
.ana-book { font-size: .72rem; padding: .08rem .45rem; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--f-quan); }
.ana-book.unsure { border: 1px dashed var(--avoid); color: var(--avoid); }
.ana-teams { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .3rem; }
.ana-team-link { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: .4rem .6rem; cursor: pointer; text-align: left; color: var(--ink); }
.ana-team-link:hover { border-color: var(--accent); }
.ana-note { font-size: .82rem; color: var(--muted); }

/* ===== Responsive ===== */
@media (max-width: 820px) {
  .top-header {
    box-shadow: var(--shadow);
  }
  .site-header {
    gap: .65rem;
    padding: .45rem .75rem;
    border-bottom: 1px solid var(--line);
  }
  .brand { gap: .45rem; min-width: 0; }
  .brand > div { min-width: 0; }
  .site-header h1 {
    font-size: .98rem;
    line-height: 1.15;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .tagline { display: none; }
  .header-actions { gap: .45rem; }
  .stats { font-size: .72rem; }
  .icon-btn {
    min-width: 2.5rem;
    min-height: 2.5rem;
    padding: .35rem;
  }
  .section-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--ink);
    cursor: pointer;
    font-size: 1.15rem;
    font-weight: 700;
    flex: 0 0 2.5rem;
    overflow: hidden;
    white-space: nowrap;
  }
  .section-menu-toggle[data-label-mode="icon"] {
    font-size: 0;
  }
  .section-menu-toggle[data-label-mode="icon"]::before {
    content: "☰";
    font-size: 1.15rem;
  }
  .layout { padding: .8rem .75rem 3rem; }
  /* Filter inline thu gọn: nút "Bộ lọc" là điều khiển chính, sắp xếp lại hàng action. */
  .team-filter-bar { padding: .7rem .75rem; }
  .team-filter-bar .filter-bar { flex-wrap: wrap; gap: .5rem; align-items: center; }
  /* Hàng 1: ô tìm kiếm full width. Hàng 2: [☰ Bộ lọc (chính)] [Xóa lọc] [stats →]. */
  .team-filter-bar .filter-bar .search { order: 1; flex: 1 1 100%; min-height: 44px; }
  .filter-collapse-toggle { order: 2; flex: 0 0 auto; }
  .team-filter-bar .clear-btn { order: 3; min-height: 44px; }
  .team-filter-bar .stats { order: 4; margin-left: auto; }
  .filter-collapse-toggle {
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
    border: 1px solid var(--line); background: var(--panel-2); color: var(--ink);
    border-radius: 9px; padding: .5rem .9rem; min-height: 44px; font-size: .85rem; font-weight: 600; cursor: pointer;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
  }
  /* Chevron chỉ trạng thái mở/đóng. */
  .filter-collapse-toggle::after { content: "▾"; font-size: .7em; transition: transform .15s ease; }
  .filter-collapse-toggle[aria-expanded="true"]::after { transform: rotate(180deg); }
  .filter-collapse-toggle:hover { border-color: var(--accent); color: var(--accent); }
  .filter-collapse-toggle[aria-expanded="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
  .filter-collapse-toggle:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); border-color: var(--accent); }
  /* Vùng nhóm lọc: mỗi nhóm 1 dòng, chip co giãn, touch thoải mái. */
  .team-filters { gap: .9rem 1rem; margin-top: .7rem; padding-top: .7rem; }
  .team-filters.collapsed { display: none; }
  .team-filters .fchip { padding: .42rem .85rem; font-size: .82rem; }
  .team-filters .fgroup { flex: 1 1 100%; max-width: none; min-width: 0; }
  .section-nav {
    display: none;
    padding: .35rem .75rem .55rem;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
  }
  .section-nav.open { display: block; }
  .section-menu-items {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    padding: 0;
  }
  .section-menu-items .nav-tab {
    width: 100%;
    min-height: 2.75rem;
    color: var(--ink);
    background: var(--panel);
    border: 1px solid transparent;
    border-radius: 8px;
    padding: .65rem .75rem;
    font-size: .9rem;
    font-weight: 700;
    text-align: left;
    white-space: nowrap;
  }
  .section-menu-items .nav-tab.active {
    background: var(--accent-soft);
    border-color: var(--accent-soft);
    color: var(--accent);
  }
  .rt-account-bar,
  .rt-section-head,
  .rt-limited {
    align-items: stretch;
    flex-direction: column;
  }
  .rt-account-main {
    min-width: 0;
    width: 100%;
  }
  .rt-select,
  .rt-account-main .rt-select {
    width: 100%;
  }
  .rt-actions {
    justify-content: flex-start;
  }
  .rt-slot-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .rt-slot {
    min-height: 8rem;
  }
  .rt-form {
    grid-template-columns: 1fr;
  }
  .rt-form-wide {
    grid-column: auto;
  }
  .rt-form input,
  .rt-form select,
  .rt-form .rt-btn {
    width: 100%;
  }
.tac-toolbar { top: 56px; }
}

.roster-recommend {
  display: grid;
  gap: 1rem;
}

.roster-token-row,
.roster-scan-grid,
.roster-review-grid {
  display: grid;
  gap: .75rem;
}

.roster-token-row {
  grid-template-columns: minmax(12rem, 1fr) minmax(10rem, 14rem) auto auto;
  align-items: center;
}

.roster-scan-grid,
.roster-review-grid {
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
}

.roster-scan-card,
.roster-review-panel,
.roster-locked-team,
.roster-result-team {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: .85rem;
}

.roster-scan-card {
  display: grid;
  gap: .65rem;
}

.roster-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.roster-chip-list li,
.roster-status {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .18rem .5rem;
  font-size: .82rem;
  background: var(--soft);
}

.roster-chip-list li {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
}

.roster-remove {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
  line-height: 1;
  padding: .05rem .1rem;
}

.roster-add-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .4rem;
  margin-top: .65rem;
}

.roster-locked-list,
.roster-results,
.roster-results section {
  display: grid;
  gap: .65rem;
}

.roster-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}

.roster-result-team.muted {
  opacity: .78;
}

.roster-empty {
  color: var(--muted);
  margin: .2rem 0 0;
}

@media (max-width: 700px) {
  .roster-token-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .rt-slot-grid {
    grid-template-columns: 1fr;
  }
  .rt-btn {
    flex: 1 1 auto;
  }
}
