/* ==========================================================================
   Cờ Vua Việt Nam — giao diện cam nhẹ
   ========================================================================== */
:root {
  --orange: #ee7a2f;
  --orange-deep: #c2571a;      /* chữ/link trên nền trắng (độ tương phản ≥ 4.5:1) */
  --orange-soft: #ffe4cc;
  --apricot: #fff4ea;
  --ink: #2a2420;
  --muted: #6e625a;
  --line: #f0e2d4;
  --surface: #ffffff;
  --sq-light: #f7e6cf;
  --sq-dark: #d9955b;
  --ok: #2f8f5b;
  --bad: #c8412e;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(120, 60, 10, .06), 0 8px 24px -12px rgba(120, 60, 10, .18);
  --wrap: 1200px;
  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { transition: none !important; animation: none !important; } }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.6; color: var(--ink); background: var(--surface); }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--orange-deep); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3, h4 { line-height: 1.22; margin: 0 0 .5em; letter-spacing: -.015em; }
h1 { font-size: clamp(1.75rem, 1.2rem + 2vw, 2.6rem); font-weight: 800; }
h2 { font-size: clamp(1.3rem, 1.1rem + .8vw, 1.75rem); font-weight: 750; }
h3 { font-size: 1.1rem; font-weight: 700; }
p { margin: 0 0 1em; }
.num, .elo { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 14px; z-index: 100; border-radius: 6px; }
.skip:focus { left: 8px; }

/* ---------- Header ---------- */
.topbar { background: var(--apricot); font-size: .85rem; color: var(--muted); }
.topbar .wrap { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 36px; }
.topbar a { color: var(--ink); }
.topbar form { display: inline; }
.topbar button.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--ink); cursor: pointer; }
.topbar-actions { display: flex; gap: 16px; align-items: center; }
.badge-due { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 10px; background: var(--orange); color: #fff; font-size: .75rem; text-align: center; font-weight: 700; }

.site-header { position: sticky; top: 0; z-index: 40; background: rgba(255, 255, 255, .94); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; gap: 24px; min-height: 68px; }
.logo { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em; white-space: nowrap; }
.logo:hover { text-decoration: none; }
.logo svg { width: 38px; height: 38px; flex: none; }
.logo small { display: block; font-weight: 500; font-size: .72rem; color: var(--muted); letter-spacing: 0; }
.nav { margin-left: auto; }
.nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 2px; }
.nav a { display: block; padding: 8px 10px; border-radius: 999px; color: var(--ink); font-weight: 600; font-size: .94rem; }
.nav a:hover { background: var(--apricot); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--orange-soft); color: #7a3a0c; }
.nav-toggle { display: none; margin-left: auto; background: none; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; cursor: pointer; }
.nav-toggle span { display: block; width: 20px; height: 2px; background: var(--ink); margin: 4px 0; }
@media (max-width: 1100px) {
  .nav-toggle { display: block; }
  .nav { position: absolute; left: 0; right: 0; top: 100%; background: #fff; border-bottom: 1px solid var(--line); display: none; }
  .nav.is-open { display: block; }
  .nav ul { flex-direction: column; padding: 8px 16px 16px; }
  .nav a { border-radius: 10px; padding: 12px; }
  .topbar .tagline { display: none; }
}

/* ---------- Buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: 999px; border: 1.5px solid transparent; font: inherit; font-weight: 650; font-size: .95rem; cursor: pointer; text-decoration: none !important; line-height: 1.2; white-space: nowrap; transition: background .15s, border-color .15s, transform .1s; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: #e06a1e; }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--orange); }
.btn-soft { background: var(--apricot); color: #7a3a0c; }
.btn-soft:hover { background: var(--orange-soft); }
.btn-sm { padding: 6px 12px; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.w-full { width: 100%; }

.field { margin-bottom: 16px; }
.field label, .label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.input, .select, .textarea { width: 100%; padding: 10px 14px; border: 1.5px solid var(--line); border-radius: 10px; font: inherit; background: #fff; color: var(--ink); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--orange); outline: none; box-shadow: 0 0 0 3px var(--orange-soft); }
.textarea { min-height: 120px; resize: vertical; }
.error-text { color: var(--bad); font-size: .85rem; margin-top: 4px; }
.hp { position: absolute; left: -5000px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

.alert { padding: 12px 16px; border-radius: 10px; margin: 16px 0; font-weight: 500; }
.alert-ok { background: #e9f6ee; color: #1e6b42; }
.alert-err { background: #fdecea; color: #9d2a1b; }

/* ---------- Page structure ---------- */
main { min-height: 50vh; }
.page-head { background: var(--apricot); padding: 28px 0 24px; margin-bottom: 32px; }
.page-head h1 { margin-bottom: 6px; }
.page-head p { color: var(--muted); max-width: 70ch; margin: 0; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 10px; }
.crumbs ol { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.crumbs li + li::before { content: "/"; margin-right: 4px; color: #c9b5a3; }
.crumbs a { color: var(--muted); }
.section { padding: 40px 0; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.section-title h2 { margin: 0; }
.section-title a { font-weight: 600; font-size: .92rem; white-space: nowrap; }
.layout-side { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 40px; }
@media (max-width: 960px) { .layout-side { grid-template-columns: 1fr; } }
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.panel-tint { background: var(--apricot); border-color: transparent; }
.panel h3 { margin-bottom: 12px; }
.stack > * + * { margin-top: 20px; }

/* ---------- Hero ---------- */
.hero { background: linear-gradient(180deg, var(--apricot) 0%, #fff 100%); padding: 40px 0 48px; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: 48px; align-items: center; }
.hero h1 { font-size: clamp(2rem, 1.3rem + 2.8vw, 3.3rem); line-height: 1.08; letter-spacing: -.03em; margin-bottom: 16px; }
.hero-lead { font-size: 1.1rem; color: var(--muted); max-width: 46ch; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin: 24px 0 32px; }
.hero-stats { display: flex; gap: 32px; flex-wrap: wrap; }
.hero-stats div { font-size: .88rem; color: var(--muted); }
.hero-stats strong { display: block; font-size: 1.6rem; color: var(--ink); font-weight: 800; font-variant-numeric: tabular-nums; }
.daily { background: #fff; border-radius: 20px; box-shadow: var(--shadow); padding: 18px; }
.daily-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.daily-head h2 { font-size: 1.05rem; margin: 0; }
.daily-head p { margin: 0; font-size: .85rem; color: var(--muted); }
@media (max-width: 900px) { .hero-grid { grid-template-columns: 1fr; gap: 28px; } }

/* ---------- News ---------- */
.news-lead { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 28px; }
.news-feature .thumb { aspect-ratio: 16/9; border-radius: var(--radius); overflow: hidden; background: var(--orange-soft); margin-bottom: 14px; }
.news-feature .thumb img { width: 100%; height: 100%; object-fit: cover; }
.news-feature h3 { font-size: 1.45rem; line-height: 1.25; }
.news-feature h3 a, .news-row h3 a, .card h3 a { color: var(--ink); }
.news-list { display: flex; flex-direction: column; }
.news-row { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); }
.news-row:first-child { border-top: 0; padding-top: 0; }
.news-row .thumb { aspect-ratio: 4/3; border-radius: 10px; overflow: hidden; background: var(--orange-soft); }
.news-row .thumb img { width: 100%; height: 100%; object-fit: cover; }
.news-row h3 { font-size: 1rem; margin-bottom: 4px; line-height: 1.35; }
.meta { font-size: .82rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.meta .cat { color: var(--orange-deep); font-weight: 600; }
.thumb-fallback { width: 100%; height: 100%; display: grid; place-items: center; background: repeating-conic-gradient(var(--sq-light) 0 25%, var(--orange-soft) 0 50%) 0 0 / 40px 40px; }
.thumb-fallback svg { width: 34%; opacity: .55; }
@media (max-width: 860px) { .news-lead { grid-template-columns: 1fr; } }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 24px; }
.card { display: flex; flex-direction: column; }
.card .thumb { aspect-ratio: 16/10; border-radius: var(--radius); overflow: hidden; background: var(--orange-soft); margin-bottom: 12px; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.card h3 { font-size: 1.05rem; line-height: 1.35; margin-bottom: 6px; }
.card p { color: var(--muted); font-size: .92rem; margin-bottom: 8px; }

/* ---------- Article ---------- */
.article { max-width: 760px; }
.article h1 { margin-bottom: 12px; }
.article .lead { font-size: 1.12rem; color: var(--muted); font-weight: 500; }
.prose { font-size: 1.05rem; line-height: 1.75; }
.prose img { border-radius: 10px; margin: 20px auto; }
.prose h2 { margin-top: 1.6em; }
.prose h3 { margin-top: 1.4em; }
.prose table { width: 100%; border-collapse: collapse; margin: 1em 0; font-size: .95rem; }
.prose th, .prose td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; }
.prose th { background: var(--apricot); }
.prose blockquote { margin: 1.4em 0; padding: 4px 0 4px 18px; border-left: 4px solid var(--orange); color: var(--muted); }
.prose ul, .prose ol { padding-left: 1.3em; }
.share { display: flex; gap: 8px; align-items: center; margin: 28px 0; flex-wrap: wrap; }

/* ---------- Tables (Elo, standings) ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.table { width: 100%; border-collapse: collapse; font-size: .94rem; }
.table th { text-align: left; font-weight: 650; font-size: .8rem; color: var(--muted); background: var(--apricot); padding: 10px 12px; white-space: nowrap; }
.table td { padding: 10px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover { background: #fffaf5; }
.table .r { text-align: right; }
.table .c { text-align: center; }
.table .rank { width: 48px; color: var(--muted); font-variant-numeric: tabular-nums; }
.table .elo { font-weight: 700; text-align: right; }
.table a { color: var(--ink); font-weight: 600; }
.table a:hover { color: var(--orange-deep); }
.table tr.top1 .rank { color: var(--orange-deep); font-weight: 800; }
.title-tag { display: inline-block; font-size: .72rem; font-weight: 800; color: #fff; background: var(--orange); border-radius: 5px; padding: 1px 5px; margin-right: 6px; vertical-align: 1px; letter-spacing: .02em; }
.title-tag.w { background: #b1477a; }
.gender { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #4d7fc0; margin-right: 6px; }
.gender.F { background: #d26a96; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 20px; }
.filters .field { margin: 0; }
.filters .input, .filters .select { padding: 9px 12px; }
.filters .grow { flex: 1 1 220px; }
.seg { display: inline-flex; background: var(--apricot); border-radius: 999px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.seg a { padding: 6px 14px; border-radius: 999px; color: var(--ink); font-weight: 600; font-size: .9rem; }
.seg a:hover { text-decoration: none; background: rgba(255, 255, 255, .7); }
.seg a.is-active { background: #fff; box-shadow: 0 1px 3px rgba(120, 60, 10, .15); color: #7a3a0c; }

/* Top 10 mini table on home */
.toplist { list-style: none; margin: 0; padding: 0; counter-reset: top; }
.toplist li { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); counter-increment: top; }
.toplist li:first-child { border-top: 0; }
.toplist li::before { content: counter(top); color: var(--muted); font-variant-numeric: tabular-nums; font-size: .85rem; text-align: right; }
.toplist a { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toplist .elo { font-weight: 750; }

/* ---------- Tournaments ---------- */
.t-list { display: flex; flex-direction: column; gap: 14px; }
.t-row { display: grid; grid-template-columns: 78px minmax(0, 1fr) auto; gap: 18px; align-items: center; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.t-row:hover { border-color: #f3c6a0; }
.t-date { text-align: center; border-radius: 12px; background: var(--apricot); padding: 8px 4px; line-height: 1.1; }
.t-date b { display: block; font-size: 1.6rem; font-weight: 800; color: var(--orange-deep); font-variant-numeric: tabular-nums; }
.t-date span { font-size: .78rem; color: var(--muted); font-weight: 600; }
.t-row h3 { margin: 0 0 4px; font-size: 1.08rem; }
.t-row h3 a { color: var(--ink); }
.status { display: inline-block; font-size: .76rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.status-upcoming { background: var(--orange-soft); color: #7a3a0c; }
.status-ongoing { background: #dff3e6; color: #1e6b42; }
.status-finished { background: #eee8e3; color: #5b524b; }
@media (max-width: 640px) { .t-row { grid-template-columns: 64px minmax(0, 1fr); } .t-row .t-cta { grid-column: 1 / -1; } }

.t-hero { background: var(--apricot); padding: 28px 0; margin-bottom: 28px; }
.t-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-top: 18px; }
.t-facts div { background: #fff; border-radius: 12px; padding: 12px 14px; }
.t-facts dt { font-size: .78rem; color: var(--muted); }
.t-facts dd { margin: 2px 0 0; font-weight: 650; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 24px; overflow-x: auto; }
.tabs a { padding: 10px 16px; font-weight: 650; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.is-active { color: var(--ink); border-color: var(--orange); }
.section-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.section-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.section-card h3 { margin-bottom: 4px; }
.section-card nav { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.round-nav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.round-nav a { min-width: 40px; text-align: center; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.round-nav a.is-active { background: var(--orange); border-color: var(--orange); color: #fff; }
.res { font-weight: 750; text-align: center; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pc { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1.5px solid #8b7b6f; vertical-align: -1px; margin-right: 6px; }
.pc.b { background: #3a312b; border-color: #3a312b; }

/* ---------- Player profile ---------- */
.profile { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 24px; align-items: center; }
.avatar { width: 120px; height: 120px; border-radius: 28px; background: var(--orange); color: #fff; display: grid; place-items: center; font-size: 2.6rem; font-weight: 800; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.ratings { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 24px 0; }
.rating-box { background: var(--apricot); border-radius: var(--radius); padding: 16px; }
.rating-box span { font-size: .82rem; color: var(--muted); }
.rating-box strong { display: block; font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.chart { width: 100%; height: auto; }
.chart .grid line { stroke: var(--line); }
.chart text { font-size: 11px; fill: var(--muted); font-family: var(--font); }
@media (max-width: 560px) { .profile { grid-template-columns: 80px 1fr; } .avatar { width: 80px; height: 80px; font-size: 1.8rem; border-radius: 20px; } .ratings { grid-template-columns: 1fr; } }

/* ---------- Board ---------- */
.cb { position: relative; width: 100%; aspect-ratio: 1; user-select: none; -webkit-user-select: none; touch-action: none; }
.cb-grid { display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); width: 100%; height: 100%; border-radius: 10px; overflow: hidden; box-shadow: 0 0 0 1px rgba(120, 60, 10, .12); }
.cb-sq { position: relative; }
.cb-light { background: var(--sq-light); }
.cb-dark { background: var(--sq-dark); }
.cb-pc { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; z-index: 2; pointer-events: none; }
.cb[data-static] .cb-pc { cursor: default; }
.cb-ghost { position: fixed; left: 0; top: 0; pointer-events: none; z-index: 1000; cursor: grabbing; }
.cb-coord { position: absolute; font-size: 10px; font-weight: 700; z-index: 1; line-height: 1; }
.cb-rank { top: 3px; left: 3px; }
.cb-file { bottom: 2px; right: 3px; }
.cb-light .cb-coord { color: var(--sq-dark); }
.cb-dark .cb-coord { color: var(--sq-light); }
.cb-last::after, .cb-sel::after, .cb-hint::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.cb-last::after { background: rgba(255, 200, 60, .42); }
.cb-sel::after { background: rgba(238, 122, 47, .55); }
.cb-hint::after { box-shadow: inset 0 0 0 4px #2f8f5b; background: rgba(47, 143, 91, .18); animation: pulse 1.4s ease-in-out infinite; }
.cb-dest::before { content: ""; position: absolute; width: 28%; height: 28%; left: 36%; top: 36%; border-radius: 50%; background: rgba(60, 30, 10, .28); z-index: 3; }
.cb-cap::before { content: ""; position: absolute; inset: 0; border-radius: 50%; box-shadow: inset 0 0 0 5px rgba(60, 30, 10, .28); z-index: 3; }
.cb-wrong::after { content: ""; position: absolute; inset: 0; background: rgba(200, 65, 46, .6); z-index: 1; }
.cb-right::after { content: ""; position: absolute; inset: 0; background: rgba(47, 143, 91, .45); z-index: 1; }
.cb-sq:focus-visible { outline: 3px solid #1d4ed8; outline-offset: -3px; z-index: 5; }
@keyframes pulse { 50% { background: rgba(47, 143, 91, .32); } }

/* ---------- Trainer ---------- */
.trainer { display: grid; grid-template-columns: minmax(0, 560px) minmax(0, 1fr); gap: 28px; align-items: start; }
.trainer-board-wrap { position: relative; }
.trainer-bar { height: 6px; background: var(--line); border-radius: 3px; margin-top: 12px; overflow: hidden; }
.trainer-bar > div { height: 100%; width: 0; background: var(--orange); transition: width .3s; }
.trainer-side { display: flex; flex-direction: column; gap: 14px; }
.trainer-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.trainer-head h2 { font-size: 1.15rem; margin: 0; }
.mode-tabs { display: inline-flex; background: var(--apricot); border-radius: 999px; padding: 4px; }
.mode-tabs button { border: 0; background: none; font: inherit; font-weight: 650; padding: 6px 14px; border-radius: 999px; cursor: pointer; color: var(--muted); }
.mode-tabs button.is-active { background: #fff; color: #7a3a0c; box-shadow: 0 1px 3px rgba(120, 60, 10, .15); }
.trainer-comment { background: var(--apricot); border-radius: var(--radius); padding: 16px 18px; min-height: 96px; font-size: 1rem; line-height: 1.65; }
.trainer-comment p { margin: 0; }
.trainer-status { font-weight: 600; padding: 10px 14px; border-radius: 10px; border: 1.5px dashed var(--line); min-height: 46px; }
.trainer-status[data-kind="turn"] { border-color: var(--orange); border-style: solid; background: #fff; }
.trainer-status[data-kind="error"] { border-color: var(--bad); color: var(--bad); border-style: solid; }
.trainer-status[data-kind="ok"] { border-color: var(--ok); color: var(--ok); border-style: solid; }
.trainer-moves { display: flex; flex-wrap: wrap; gap: 2px 6px; font-size: .95rem; line-height: 1.9; min-height: 40px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-variant-numeric: tabular-nums; }
.mv-n { color: var(--muted); }
.mv { font-weight: 600; padding: 0 4px; border-radius: 5px; }
.mv.is-mine { color: #7a3a0c; }
.mv.is-current { background: var(--orange-soft); }
.mv-q { color: var(--orange); }
.trainer-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.trainer-done { background: #fff; border: 1.5px solid var(--orange); border-radius: var(--radius); padding: 16px; }
.trainer-done .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.trainer.is-train .learn-only { display: none; }
.trainer:not(.is-train) .train-only { display: none; }
@media (max-width: 900px) { .trainer { grid-template-columns: 1fr; } }
.trainer.compact { grid-template-columns: 1fr; gap: 12px; }
.trainer.compact .trainer-comment { min-height: 0; padding: 12px 14px; font-size: .93rem; }

/* ---------- Courses ---------- */
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 24px; }
.course-card { border: 1px solid var(--line); border-radius: 18px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.course-card .cover { padding: 18px 18px 0; background: var(--apricot); }
.course-card .cover .cb { max-width: 210px; margin: 0 auto; transform: translateY(10px); }
.course-card .body { padding: 26px 18px 18px; display: flex; flex-direction: column; flex: 1; }
.course-card h3 { margin-bottom: 6px; }
.course-card h3 a { color: var(--ink); }
.course-card p { color: var(--muted); font-size: .92rem; flex: 1; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { font-size: .76rem; font-weight: 650; padding: 3px 10px; border-radius: 999px; background: var(--apricot); color: #7a3a0c; }
.chip.dark { background: #3a312b; color: #fff; }
.progress { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin: 10px 0 4px; }
.progress > div { height: 100%; background: var(--orange); }
.chapter { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; overflow: hidden; }
.chapter > header { padding: 14px 18px; background: var(--apricot); display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.chapter > header h3 { margin: 0; }
.chapter ol { list-style: none; margin: 0; padding: 0; }
.chapter li { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line); }
.chapter li:first-child { border-top: 0; }
.lvl { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: .78rem; font-weight: 800; background: #f1ebe5; color: var(--muted); }
.lvl.on { background: var(--orange); color: #fff; }
.lvl.due { background: #fff; color: var(--orange-deep); box-shadow: inset 0 0 0 2px var(--orange); }
.chapter li a.title { color: var(--ink); font-weight: 600; }

/* ---------- Docs & videos ---------- */
.doc-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); }
.doc-icon { width: 44px; height: 52px; border-radius: 8px; background: var(--orange-soft); color: var(--orange-deep); display: grid; place-items: center; font-size: .7rem; font-weight: 800; }
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 24px; }
.video { position: relative; aspect-ratio: 16/9; border-radius: var(--radius); overflow: hidden; background: #000; }
.video img, .video iframe { width: 100%; height: 100%; object-fit: cover; border: 0; }
.video button { position: absolute; inset: 0; background: none; border: 0; cursor: pointer; display: grid; place-items: center; }
.video button span { width: 64px; height: 64px; border-radius: 50%; background: rgba(238, 122, 47, .92); display: grid; place-items: center; }

/* ---------- Pagination ---------- */
.pager { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin: 32px 0 8px; list-style: none; padding: 0; }
.pager a, .pager span { min-width: 40px; height: 40px; display: grid; place-items: center; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line); color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.pager a:hover { border-color: var(--orange); text-decoration: none; }
.pager .is-active span { background: var(--orange); border-color: var(--orange); color: #fff; }
.pager .is-disabled span { color: #cbbcb0; }

/* ---------- Footer ---------- */
.partners { border-top: 1px solid var(--line); padding: 24px 0; }
.partners .wrap { display: flex; flex-wrap: wrap; gap: 28px; align-items: center; justify-content: center; }
.partners img { height: 40px; width: auto; filter: grayscale(1); opacity: .7; }
.partners a:hover img { filter: none; opacity: 1; }
.site-footer { background: #2a2420; color: #d9cfc6; padding: 44px 0 24px; margin-top: 56px; font-size: .92rem; }
.site-footer a { color: #fff; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 32px; }
.footer-grid h2 { font-size: .95rem; color: #fff; margin-bottom: 12px; }
.footer-grid ul { list-style: none; padding: 0; margin: 0; }
.footer-grid li { margin-bottom: 8px; }
.footer-bottom { border-top: 1px solid #463c35; margin-top: 32px; padding-top: 18px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; font-size: .82rem; color: #a99a8e; }
@media (max-width: 860px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .footer-grid { grid-template-columns: 1fr; } }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); border: 1.5px dashed var(--line); border-radius: var(--radius); }
.auth-box { max-width: 440px; margin: 0 auto; }
.thumb .thumb-fallback img.fb-piece { width: 34%; height: auto; opacity: .55; object-fit: contain; }

/* ---------- Ván đấu ---------- */
.games-table td { padding-top: 8px; padding-bottom: 8px; }
.game-head { padding: 8px 0 20px; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.game-players { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 16px; align-items: center; }
.game-players .gp { font-size: clamp(1.05rem, .9rem + .7vw, 1.45rem); font-weight: 700; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.game-players .gp:last-child { justify-content: flex-end; text-align: right; }
.game-players .gp a { color: var(--ink); }
.game-players .gp .pc { margin: 0; }
.game-score { font-size: clamp(1.4rem, 1.1rem + 1vw, 2rem); font-weight: 800; color: var(--orange-deep); white-space: nowrap; background: var(--apricot); padding: 4px 16px; border-radius: 12px; }
@media (max-width: 640px) {
  .game-players { grid-template-columns: 1fr; gap: 6px; }
  .game-players .gp:last-child { justify-content: flex-start; text-align: left; }
  .game-score { justify-self: start; }
}
.viewer { display: grid; grid-template-columns: minmax(0, 560px) minmax(0, 1fr); gap: 28px; align-items: start; }
.viewer-controls { display: flex; gap: 6px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.viewer-controls .btn { min-width: 44px; }
.viewer-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.viewer-comment { background: var(--apricot); border-radius: 12px; padding: 12px 14px; font-size: .95rem; }
.viewer-moves { border: 1px solid var(--line); border-radius: 12px; max-height: 440px; overflow-y: auto; font-variant-numeric: tabular-nums; position: relative; }
.vm-row { display: grid; grid-template-columns: 52px 1fr 1fr; border-top: 1px solid #f7ede4; }
.vm-row:first-child { border-top: 0; }
.vm-n { padding: 6px 10px; color: var(--muted); background: #fdf8f3; font-size: .88rem; }
.vm-cell { padding: 6px 10px; color: var(--ink); font-weight: 600; }
a.vm-cell:hover { background: var(--apricot); text-decoration: none; }
.vm-cell.is-current { background: var(--orange); color: #fff; }
.vm-empty { color: var(--muted); font-weight: 400; }
.vm-nag { color: var(--orange-deep); margin-left: 1px; }
.vm-cell.is-current .vm-nag { color: #fff; }
.vm-comment { padding: 6px 12px 8px 62px; font-size: .88rem; color: var(--muted); border-top: 1px solid #f7ede4; background: #fffcf9; }
.vm-result { padding: 8px 12px; text-align: center; font-weight: 800; border-top: 1px solid var(--line); }
.viewer-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.game-facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: .94rem; }
.game-facts dt { color: var(--muted); }
.game-facts dd { margin: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
@media (max-width: 900px) { .viewer { grid-template-columns: 1fr; } .viewer-moves { max-height: 300px; } }

/* ---------- Xu thưởng ---------- */
.coin-chip { display: inline-flex; align-items: center; gap: 4px; background: #fff; border-radius: 999px; padding: 1px 10px 1px 6px; font-weight: 700; color: #7a3a0c !important; }
.coin-chip img { display: inline; }
.up { color: var(--ok); }
.down { color: var(--bad); }

/* ---------- Bài tập ---------- */
.pz-hero { background: linear-gradient(135deg, #fff4ea 0%, #ffe9d6 100%); padding: 28px 0 32px; margin-bottom: 32px; }
.pz-hero-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 32px; align-items: center; }
.pz-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.pz-stats div { background: #fff; border-radius: 16px; padding: 16px; text-align: center; box-shadow: var(--shadow); }
.pz-stats strong { display: block; font-size: clamp(1.15rem, .9rem + 1.6vw, 1.7rem); font-weight: 800; color: var(--orange-deep); line-height: 1.1; }
.pz-stats span { font-size: .82rem; color: var(--muted); }
@media (max-width: 860px) { .pz-hero-grid { grid-template-columns: 1fr; } }
.pz-themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.pz-theme { display: flex; gap: 16px; align-items: center; padding: 18px; border-radius: 18px; background: #fff; border: 1px solid var(--line); color: var(--ink); position: relative; overflow: hidden; transition: transform .15s, box-shadow .15s; }
.pz-theme::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 6px; background: var(--accent); }
.pz-theme:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow); }
.pz-theme img { flex: none; background: color-mix(in srgb, var(--accent) 14%, white); border-radius: 16px; padding: 6px; width: 68px; height: 68px; }
.pz-theme h3 { margin: 0 0 4px; }
.pz-theme p { margin: 0 0 4px; font-size: .9rem; color: var(--muted); }
.pz-levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.pz-level { border-radius: 16px; padding: 16px; color: #fff; display: flex; flex-direction: column; gap: 2px; transition: transform .15s; }
.pz-level:hover { text-decoration: none; transform: translateY(-2px); }
.pz-level strong { font-size: 1.1rem; }
.pz-level span { font-weight: 700; opacity: .95; }
.pz-level small { opacity: .85; }
.lv-0 { background: linear-gradient(135deg, #5cc48a, #2f8f5b); }
.lv-1 { background: linear-gradient(135deg, #5fb6e8, #2f7fc0); }
.lv-2 { background: linear-gradient(135deg, #f4b54a, #e08a1e); }
.lv-3 { background: linear-gradient(135deg, #f08a4b, #d4581c); }
.lv-4 { background: linear-gradient(135deg, #e5677d, #b8344f); }
.lv-5 { background: linear-gradient(135deg, #8f6ee0, #5a3cb8); }
.pz-leader { display: grid; grid-template-columns: 24px 1fr auto; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); font-size: .92rem; }
.pz-leader:first-of-type { border-top: 0; }
.pz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.pz-tile { position: relative; display: block; border: 1px solid var(--line); border-radius: 12px; padding: 8px; color: var(--ink); background: #fff; }
.pz-tile:hover { text-decoration: none; border-color: var(--orange); }
.pz-tile-meta { display: flex; justify-content: space-between; font-size: .82rem; margin-top: 6px; }
.pz-tile.is-solved { border-color: #9fd9b7; background: #f3fbf6; }
.pz-tile.is-failed { border-color: #f1b5aa; background: #fdf5f3; }
.pz-badge { position: absolute; top: 4px; right: 4px; z-index: 6; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; background: var(--ok); font-size: .8rem; }
.pz-tile.is-failed .pz-badge { background: var(--bad); }
.pz-rating { text-align: right; }
.pz-rating strong { display: block; font-size: 1.6rem; font-weight: 800; color: var(--orange-deep); line-height: 1; }
.pz-result { border-radius: 14px; padding: 14px 16px; background: linear-gradient(135deg, #fff4ea, #ffe4cc); }
.pz-result p { margin: 0; }
.pz-result .p-rating { font-size: 1.05rem; }
.pz-result .p-coins { font-size: 1.5rem; font-weight: 800; color: #b7791f; }
.puzzle.is-failed .trainer-status { animation: shake .35s; }
.puzzle .trainer-side { min-height: 100%; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* ---------- Thú cưng ---------- */
.pet-hero { background: radial-gradient(circle at 80% 20%, #ffe0f0 0, transparent 40%), radial-gradient(circle at 20% 80%, #dff6ff 0, transparent 45%), linear-gradient(135deg, #fff4ea, #fff); padding: 28px 0 36px; }
.pet-hero-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 24px; align-items: center; }
.pet-wallet { display: inline-flex; align-items: center; gap: 8px; background: #fff; border-radius: 999px; padding: 8px 18px; box-shadow: var(--shadow); font-size: 1.15rem; }
.pet-parade { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.pet-parade img { width: 100%; max-width: 110px; margin: auto; animation: bob 2.6s ease-in-out infinite; animation-delay: var(--d); filter: drop-shadow(0 8px 10px rgba(120, 60, 10, .18)); }
@keyframes bob { 50% { transform: translateY(-10px) rotate(-3deg); } }
@media (max-width: 860px) { .pet-hero-grid { grid-template-columns: 1fr; } .pet-parade { grid-template-columns: repeat(6, 1fr); } }
.earn { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin: -18px 0 8px; position: relative; }
.earn > div { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: grid; grid-template-columns: 40px 1fr; gap: 2px 10px; align-items: center; }
.earn img { grid-row: span 2; width: 40px; height: 40px; }
.earn strong { font-size: .92rem; }
.earn span { font-size: .8rem; color: var(--muted); }

.rarity-common { --r1: #e6f7ee; --r2: #c9eedc; --rc: #2f8f5b; }
.rarity-rare { --r1: #e5f1ff; --r2: #c7dcff; --rc: #2f6fd0; }
.rarity-epic { --r1: #f5e8ff; --r2: #e3c9ff; --rc: #8a3fd1; }
.rarity-legendary { --r1: #fff4cf; --r2: #ffd77a; --rc: #b7791f; }
.rarity-chip { display: inline-block; font-size: .72rem; font-weight: 800; padding: 2px 10px; border-radius: 999px; background: var(--rc); color: #fff; }

.pet-shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.pet-card { position: relative; border-radius: 20px; padding: 14px 14px 16px; background: linear-gradient(160deg, var(--r1), #fff 70%); border: 2px solid var(--r2); text-align: center; display: flex; flex-direction: column; }
.pet-card .rarity-chip { position: absolute; top: 10px; left: 10px; }
.pet-card .pc-img { width: 104px; height: 104px; margin: 14px auto 8px; animation: bob 3s ease-in-out infinite; animation-delay: var(--d); filter: drop-shadow(0 8px 8px rgba(0, 0, 0, .12)); }
.pet-card h3 { margin: 0 0 4px; font-size: 1.02rem; }
.pet-card p { font-size: .82rem; color: var(--muted); flex: 1; margin: 0 0 8px; }
.pet-card .pc-meta { font-size: .76rem; color: var(--rc); font-weight: 600; margin-bottom: 10px; }
.pet-card.rarity-legendary { box-shadow: 0 0 0 1px #ffd77a, 0 10px 28px -10px rgba(214, 150, 20, .55); }
.pet-card.rarity-legendary::after { content: ""; position: absolute; inset: 0; border-radius: 18px; pointer-events: none; background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .55) 45%, transparent 60%); background-size: 250% 100%; animation: shine 3.5s linear infinite; }
@keyframes shine { from { background-position: 150% 0; } to { background-position: -100% 0; } }
.pet-card.is-locked .pc-img { filter: grayscale(.85) opacity(.55); animation: none; }
.pet-card[hidden] { display: none; }

.my-pets { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 18px; }
@media (max-width: 520px) { .my-pets { grid-template-columns: 1fr; } }
.my-pet { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 16px; border-radius: 22px; padding: 16px; background: linear-gradient(160deg, var(--r1), #fff 75%); border: 2px solid var(--r2); }
.my-pet.is-active { box-shadow: 0 0 0 3px var(--orange); }
.mp-stage { position: relative; display: grid; place-items: end center; min-height: 170px; background: radial-gradient(ellipse at 50% 92%, rgba(0, 0, 0, .10) 0 22%, transparent 23%); }
.mp-img { width: 120px; height: 120px; animation: bob 2.4s ease-in-out infinite; filter: drop-shadow(0 8px 8px rgba(0, 0, 0, .15)); transform-origin: bottom center; }
.stage-baby .mp-img { width: 86px; height: 86px; }
.stage-teen .mp-img { width: 108px; height: 108px; }
.stage-adult .mp-img { width: 132px; height: 132px; }
.mp-acc { position: absolute; width: 38px; top: 18px; right: 14px; animation: bob 2s ease-in-out infinite .4s; }
.mp-mood { position: absolute; width: 30px; bottom: 96px; left: 10px; }
.mp-bubble { position: absolute; top: 0; left: 0; right: 0; background: #fff; border-radius: 12px; padding: 6px 8px; font-size: .74rem; line-height: 1.3; box-shadow: var(--shadow); text-align: center; }
.mood-hungry .mp-img { animation-duration: 4s; filter: grayscale(.3) drop-shadow(0 8px 8px rgba(0, 0, 0, .15)); }
.mp-title { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.mp-title h3 { margin: 0; font-size: 1.15rem; }
.bar { display: grid; grid-template-columns: 54px 1fr 54px; gap: 8px; align-items: center; font-size: .78rem; margin-bottom: 6px; }
.bar > div { height: 9px; background: rgba(0, 0, 0, .07); border-radius: 5px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #8f6ee0, #c08bff); border-radius: 5px; transition: width .4s; }
.bar.hunger i { background: linear-gradient(90deg, #f0a03c, #f5c35a); }
.bar.happy i { background: linear-gradient(90deg, #e5677d, #ff9db0); }
.bar small { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.mp-food { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.mp-food form { margin: 0; }
.food-btn { position: relative; width: 42px; height: 42px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; cursor: pointer; padding: 5px; }
.food-btn.fav { border-color: var(--orange); background: #fff7ef; }
.food-btn img { width: 100%; height: 100%; }
.food-btn b { position: absolute; right: -6px; bottom: -6px; background: var(--ink); color: #fff; font-size: .66rem; min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; }
.food-btn:hover { transform: translateY(-2px); }
.mp-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.mp-actions form { margin: 0; }
.food-shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.food-card { display: grid; grid-template-columns: 56px 1fr; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.food-card img { width: 56px; height: 56px; }
.food-card h3 { margin: 0; font-size: .98rem; }
.food-card p { margin: 2px 0 6px; }
.food-buy { display: flex; gap: 6px; flex-wrap: wrap; }
.pb-jump { animation: jump .7s ease !important; }
.pb-shake { animation: shake .4s ease !important; }
@keyframes jump { 30% { transform: translateY(-26px) scale(1.08); } 60% { transform: translateY(0) scale(.96); } }

/* Bạn đồng hành */
.pet-buddy { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; pointer-events: none; }
.pet-buddy > * { pointer-events: auto; }
.pet-buddy button { position: relative; width: 78px; height: 78px; border-radius: 50%; border: 3px solid #fff; background: radial-gradient(circle at 50% 35%, #fff, #ffe4cc); box-shadow: 0 8px 22px -6px rgba(120, 60, 10, .45); cursor: pointer; padding: 6px; }
.pet-buddy img { width: 100%; height: 100%; animation: bob 2.6s ease-in-out infinite; }
.pb-level { position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%); background: var(--orange); color: #fff; font-size: .66rem; font-weight: 800; padding: 1px 7px; border-radius: 8px; white-space: nowrap; }
.pb-bubble { max-width: 220px; background: #fff; border-radius: 14px 14px 4px 14px; padding: 8px 12px; font-size: .85rem; font-weight: 600; box-shadow: var(--shadow); opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }
.pet-buddy.is-talking .pb-bubble { opacity: 1; transform: none; }
.pb-link { font-size: .72rem; background: rgba(255, 255, 255, .9); border-radius: 8px; padding: 0 6px; color: var(--muted); }
@media (max-width: 640px) { .pet-buddy button { width: 60px; height: 60px; } .pb-link { display: none; } }
@media (prefers-reduced-motion: reduce) { .pet-card .pc-img, .mp-img, .pet-parade img, .pet-buddy img { animation: none; } }

/* ---------- Trang giải bài (bố cục bảng điều khiển) ---------- */
.pzapp { background: linear-gradient(180deg, #fff4ea 0%, #fffaf5 60%, #fff 100%); padding: 18px 0 40px; }
.pzapp-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
.pzapp-hello { display: flex; align-items: center; gap: 12px; }
.pzapp-mascot { width: 52px; height: 52px; background: #fff; border-radius: 16px; padding: 5px; box-shadow: var(--shadow); }
.pzapp-hello h1 { font-size: clamp(1.25rem, 1rem + 1vw, 1.7rem); margin: 0; }
.pzapp-hello p { margin: 0; color: var(--muted); font-weight: 600; font-size: .95rem; min-height: 1.5em; }
.pzapp-pill { background: linear-gradient(135deg, #8ee6a8, #5cc48a); color: #0f3d24; font-weight: 800; padding: 10px 20px; border-radius: 999px; white-space: nowrap; box-shadow: 0 8px 18px -10px rgba(47, 143, 91, .8); font-variant-numeric: tabular-nums; }
.pzapp-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); gap: 24px; align-items: start; }
@media (max-width: 920px) { .pzapp-grid { grid-template-columns: 1fr; } }
.pzapp-board-card { background: #fff; border-radius: 28px; padding: 20px 22px 14px; box-shadow: 0 1px 2px rgba(120, 60, 10, .06), 0 20px 40px -24px rgba(120, 60, 10, .35); }
.pzapp-board-frame { display: grid; grid-template-columns: 26px minmax(0, 1fr); grid-template-rows: auto 28px; max-width: 640px; margin: 0 auto; }
.pzapp-ranks { display: grid; grid-template-rows: repeat(8, 1fr); align-items: center; font-weight: 700; color: var(--muted); font-size: .95rem; }
.pzapp-files { display: grid; grid-template-columns: repeat(8, 1fr); text-align: center; font-weight: 700; color: var(--muted); font-size: .95rem; padding-top: 6px; }
.pzapp.no-coords .pzapp-ranks, .pzapp.no-coords .pzapp-files { visibility: hidden; }
.pzapp-board .cb-grid { border-radius: 16px; box-shadow: none; }
.pzapp[data-board-theme="blue"] { --sq-light: #f3f7fc; --sq-dark: #8db9dc; }
.pzapp[data-board-theme="wood"] { --sq-light: #f7e6cf; --sq-dark: #d9955b; }
.pzapp[data-board-theme="green"] { --sq-light: #eeeed2; --sq-dark: #86a666; }
.pzapp[data-board-theme="gray"] { --sq-light: #ececec; --sq-dark: #aab0b6; }
.pzapp.is-solved .pzapp-board .cb-grid { box-shadow: 0 0 0 4px #8ee6a8; }
.pzapp.is-failed .pzapp-board .cb-grid { box-shadow: 0 0 0 4px #f6b7ab; }

.pzapp-panel { background: #fff; border-radius: 28px; padding: 22px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 1px 2px rgba(120, 60, 10, .06), 0 20px 40px -24px rgba(120, 60, 10, .35); }
.pzapp-eyebrow { display: block; color: #2f8f5b; font-weight: 800; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; }
.pzapp-title h2 { font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem); margin: 2px 0 0; letter-spacing: -.02em; }
.pzapp-card { background: #fffaf5; border: 1px solid var(--line); border-radius: 20px; padding: 14px 16px; }
.pzapp-label { font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; font-weight: 800; }
.pzapp-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.pzapp-progress .pzapp-row strong { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.pzapp-bar { height: 10px; background: #f0e2d4; border-radius: 6px; overflow: hidden; margin: 10px 0 8px; }
.pzapp-bar i { display: block; height: 100%; width: 4%; background: linear-gradient(90deg, #f5d36b, #8ee6a8); border-radius: 6px; transition: width .4s; }
.pzapp-dots { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.pzapp-dots .dot { width: 16px; height: 16px; border-radius: 50%; border: 0; padding: 0; cursor: pointer; background: #ead9c8; }
.pzapp-dots .dot.st-ok { background: #5cc48a; }
.pzapp-dots .dot.st-bad { background: #ef8a76; }
.pzapp-dots .dot.st-old { background: #c9bdb2; }
.pzapp-dots .dot.cur { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--orange); }
.pzapp-controls { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.pzapp-controls button { display: flex; flex-direction: column; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 10px 4px; font: inherit; font-size: .85rem; font-weight: 700; color: var(--ink); cursor: pointer; transition: transform .1s, border-color .15s; }
.pzapp-controls button:hover { border-color: var(--orange); transform: translateY(-1px); }
.pzapp-controls .ic { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle at 35% 30%, #ffc27a, #ee7a2f 70%); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .12); }
.pzapp-controls svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.pzapp-feedback { background: #fff; }
.pzapp-status { margin: 0; font-weight: 700; }
.pzapp-status[data-kind="ok"] { color: var(--ok); }
.pzapp-status[data-kind="error"] { color: var(--bad); }
.pzapp-result { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-top: 8px; font-weight: 700; }
.pzapp-coin { color: #b7791f; font-size: 1.15rem; }
.pzapp-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.pzapp-turn { display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 10px 14px; }
.pzapp-turn-ic { width: 52px; height: 52px; border-radius: 14px; background: #fff4ea; display: grid; place-items: center; }
.pzapp-turn-ic img { width: 40px; height: 40px; }
.pzapp-turn small, .pzapp-diff small { display: block; color: var(--muted); font-size: .78rem; }
.pzapp-turn strong { font-size: 1.15rem; }
.pzapp-diff { text-align: right; }
.pzapp-diff strong { color: var(--orange-deep); }
.pzapp-ext { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.pzapp-ext a { display: flex; justify-content: center; align-items: center; gap: 8px; padding: 12px; border-radius: 14px; background: #fff; border: 1px solid var(--line); color: var(--ink); font-weight: 700; }
.pzapp-ext a:hover { border-color: var(--orange); text-decoration: none; }
.pzapp-ext svg { width: 18px; height: 18px; fill: none; stroke: var(--orange); stroke-width: 2.4; stroke-linecap: round; }
.pzapp-tip { margin: 0; padding: 10px 14px; border-radius: 14px; border: 1.5px dashed #f0d2b6; font-size: .88rem; color: var(--muted); }
.pzapp-modal { position: fixed; inset: 0; background: rgba(42, 36, 32, .35); display: grid; place-items: center; z-index: 100; padding: 16px; }
.pzapp-modal[hidden] { display: none; }
.pzapp-modal-box { background: #fff; border-radius: 22px; padding: 22px; width: min(420px, 100%); box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .35); }
.pzapp-modal-box h3 { margin-top: 0; }
.pzapp-modal fieldset { border: 0; padding: 0; margin: 0 0 12px; }
.pzapp-modal legend { font-weight: 700; margin-bottom: 8px; }
.pzapp-swatches { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.pzapp-swatches label { display: flex; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; font-size: .9rem; }
.pzapp-swatches input { accent-color: var(--orange); }
.sw { width: 28px; height: 28px; border-radius: 6px; flex: none; }
.sw-blue { background: conic-gradient(#8db9dc 0 25%, #f3f7fc 0 50%, #8db9dc 0 75%, #f3f7fc 0); }
.sw-wood { background: conic-gradient(#d9955b 0 25%, #f7e6cf 0 50%, #d9955b 0 75%, #f7e6cf 0); }
.sw-green { background: conic-gradient(#86a666 0 25%, #eeeed2 0 50%, #86a666 0 75%, #eeeed2 0); }
.sw-gray { background: conic-gradient(#aab0b6 0 25%, #ececec 0 50%, #aab0b6 0 75%, #ececec 0); }
.pzapp-check { display: flex; gap: 8px; align-items: center; margin: 8px 0; font-weight: 500; }
.pzapp-check input { width: 18px; height: 18px; accent-color: var(--orange); }
@media (max-width: 520px) {
  .pzapp-board-card { padding: 12px 10px 8px; border-radius: 20px; }
  .pzapp-board-frame { grid-template-columns: 18px minmax(0, 1fr); grid-template-rows: auto 22px; }
  .pzapp-ranks, .pzapp-files { font-size: .75rem; }
  .pzapp-controls { gap: 4px; }
  .pzapp-controls button { font-size: .72rem; padding: 8px 2px; }
  .pzapp-controls .ic { width: 32px; height: 32px; }
  .pzapp-pill { padding: 8px 14px; }
}

@media (max-width: 560px) { .topbar-actions { gap: 10px; } .topbar .hide-sm { display: none; } }

/* ---------- Chuyên đề Bắt đôi ---------- */
.pz-special { margin-top: 40px; padding: 24px; border-radius: 20px; background: linear-gradient(135deg, #fff6ec, #fff 60%); border: 1px solid #f6dcc2; }
.pz-special-head h2 { margin: 4px 0 4px; }
.pz-special-head p { margin: 0 0 16px; }
.pz-special-tag { display: inline-block; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #fff; background: var(--orange, #ee7a2f); padding: 3px 10px; border-radius: 999px; }
.pz-fork-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.pz-fork { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: #fff; border: 1px solid #f1e3d4; border-left: 4px solid var(--accent); border-radius: 14px; color: inherit; transition: transform .15s, box-shadow .15s; }
.pz-fork:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 6px 18px rgba(150, 80, 20, .12); }
.pz-fork-ic { flex: 0 0 52px; height: 52px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 14%, #fff); }
.pz-fork-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pz-fork-body strong { font-size: .98rem; line-height: 1.25; }
.pz-fork-body small { color: var(--muted, #8a7a6c); }
.pz-fork-bar { display: block; height: 5px; background: #f3e8dc; border-radius: 9px; overflow: hidden; margin-top: 4px; }
.pz-fork-bar b { display: block; height: 100%; background: var(--accent); }
.pz-fork-go { font-size: 1.6rem; color: var(--accent); line-height: 1; }
@media (max-width: 560px) { .pz-special { padding: 16px; } }

/* ---------- Trang chủ đề bài tập (landing SEO) ---------- */
.pzt-hero { background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 12%, #fff7ef), #fff 70%); border-bottom: 1px solid #f3e3d2; padding: 28px 0 32px; }
.pzt-hero-grid { display: grid; grid-template-columns: 1fr 300px; gap: 32px; align-items: center; }
.pzt-hero h1 { margin: 6px 0 10px; }
.pzt-kicker { display: inline-block; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); background: #fff; border: 1px solid color-mix(in srgb, var(--accent) 35%, #fff); padding: 3px 10px; border-radius: 999px; margin-top: 8px; }
.pzt-facts { background: #fff; border-radius: 20px; padding: 18px; box-shadow: 0 10px 30px rgba(150, 80, 20, .1); display: flex; gap: 16px; align-items: center; }
.pzt-facts img { background: color-mix(in srgb, var(--accent) 12%, #fff); border-radius: 18px; padding: 8px; flex: 0 0 auto; }
.pzt-facts dl { margin: 0; display: grid; gap: 6px; flex: 1; }
.pzt-facts dl div { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dashed #f0e2d3; padding-bottom: 4px; }
.pzt-facts dt { color: var(--muted, #8a7a6c); font-size: .88rem; }
.pzt-facts dd { margin: 0; font-weight: 700; }
.pzt-layout { margin-top: 28px; }
.pzt-article { background: #fff; border: 1px solid #f3e6d8; border-radius: 18px; padding: 22px 26px; margin-bottom: 28px; }
.pzt-article h2 { font-size: 1.25rem; margin-top: 1.2em; }
.pzt-article h2:first-child { margin-top: 0; }
.pzt-faq { margin-top: 36px; }
.pzt-faq details { background: #fff; border: 1px solid #f1e3d4; border-radius: 12px; padding: 12px 16px; margin-bottom: 10px; }
.pzt-faq summary { font-weight: 700; cursor: pointer; }
.pzt-faq details p { margin: 8px 0 0; color: #4a3d33; }
.pzt-cta { border-top: 4px solid var(--accent); }
.pzt-related { list-style: none; margin: 0; padding: 0; }
.pzt-related a { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-radius: 8px; color: inherit; }
.pzt-related a:hover { background: #fff4ea; text-decoration: none; }
.pzt-related span { flex: 1; }
.pzt-related small { color: var(--muted, #8a7a6c); }
@media (max-width: 860px) { .pzt-hero-grid { grid-template-columns: 1fr; } .pzt-article { padding: 18px; } }

/* ---------- Danh mục chuyên đề bài tập ---------- */
.pz-catalog { margin-top: 44px; }
.pz-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.pz-chips a { display: inline-flex; gap: 6px; align-items: center; padding: 7px 14px; border-radius: 999px; background: #fff; border: 1px solid #f0dcc6; color: var(--ink); font-weight: 600; font-size: .92rem; }
.pz-chips a:hover { background: #fff1e4; text-decoration: none; }
.pz-chips .num { color: var(--muted, #8a7a6c); font-weight: 500; font-size: .82rem; }
.pz-special { scroll-margin-top: 90px; margin-top: 24px; }

/* Ảnh kỳ thủ (từ FIDE) phủ lên chữ viết tắt; lỗi tải ảnh thì hiện chữ viết tắt */
.avatar { position: relative; }
.avatar img { position: absolute; inset: 0; }

/* ---------- Thư viện khai cuộc ---------- */
.op-group { margin-top: 28px; }
.op-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.op-card { display: grid; grid-template-columns: 112px 1fr; gap: 14px; background: #fff; border: 1px solid #f1e3d4; border-radius: 16px; padding: 12px; }
.op-card:hover { box-shadow: 0 6px 18px rgba(150, 80, 20, .1); }
.op-card-board { display: block; width: 112px; }
.op-card h3 { font-size: 1.02rem; margin: 2px 0 2px; }
.op-card h3 a { color: inherit; }
.op-mini { list-style: none; margin: 0; padding: 0; font-size: .88rem; }
.op-mini li { padding: 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.op-moves-box { background: #fff7ef; border: 1px solid #f3e1cd; border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }
@media (max-width: 480px) { .op-card { grid-template-columns: 84px 1fr; } .op-card-board { width: 84px; } }
.op-card-body { min-width: 0; }
.op-card-body p { overflow-wrap: anywhere; }
