/* Code Vàng — hệ màu và chữ
   Ink #1B2340 · Paper #F4F6FD · Cobalt #2F4BFF · Ticket #FFD43B · Live #0F9D58 · Dead #D9DCE6 */
:root {
  --ink: #1b2340;
  --ink-soft: #4a5275;
  --paper: #f4f6fd;
  --surface: #ffffff;
  --line: #dde2f2;
  --cobalt: #2f4bff;
  --cobalt-deep: #1d33cc;
  --ticket: #ffd43b;
  --ticket-pale: #fff3c4;
  --ticket-ink: #3b2f00;
  --live: #0f9d58;
  --dead: #d9dce6;
  --dead-ink: #6b7190;
  --font-display: 'Baloo 2', 'Lexend', system-ui, sans-serif;
  --font-body: 'Lexend', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-code: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --step--1: 0.84rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.56rem;
  --step-3: 1.95rem;
  --step-4: 2.44rem;
  --measure: 68ch;
  --gutter: 16px;
  --radius-ticket: 14px;
  --radius-ui: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8ebfa;
    --ink-soft: #a9b0d1;
    --paper: #11162b;
    --surface: #1a2140;
    --line: #2b3460;
    --cobalt: #7c8dff;
    --cobalt-deep: #a3afff;
    --dead: #2b3254;
    --dead-ink: #8d93b3;
    --live: #3ccf86;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.65;
}
img, svg, video { max-width: 100%; height: auto; }
a { color: var(--cobalt); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--cobalt-deep); text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 {
  font-family: var(--font-display);
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0;
  text-wrap: balance;
}
h1 { font-size: clamp(var(--step-3), 6vw, var(--step-4)); }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); font-weight: 700; }

.wrap { width: 100%; max-width: 1040px; margin-inline: auto; padding-inline: var(--gutter); }
.screen-reader-text {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; margin: -1px;
}
.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 16px; top: 12px; z-index: 100; background: var(--surface); padding: 8px 14px; border-radius: var(--radius-ui); }

/* ---------- Header ---------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-header .bar { display: flex; align-items: center; gap: 16px 20px; min-height: 64px; flex-wrap: wrap; padding-block: 10px; }
.logo {
  display: inline-flex; align-items: center; gap: 4px; text-decoration: none;
  font-family: var(--font-display); font-weight: 800; font-size: 1.6rem; line-height: 1; color: var(--ink);
}
.logo:hover { color: var(--ink); }
.logo-ticket {
  background: var(--ticket); color: var(--ticket-ink); padding: 4px 10px 2px; border-radius: 8px;
  -webkit-mask: radial-gradient(circle 5px at 0 50%, #0000 98%, #000) left / 51% 100% no-repeat,
    radial-gradient(circle 5px at 100% 50%, #0000 98%, #000) right / 51% 100% no-repeat;
  mask: radial-gradient(circle 5px at 0 50%, #0000 98%, #000) left / 51% 100% no-repeat,
    radial-gradient(circle 5px at 100% 50%, #0000 98%, #000) right / 51% 100% no-repeat;
}
.logo.small { font-size: 1.3rem; }
.primary-nav { margin-left: auto; }
.primary-nav ul { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }
.primary-nav a {
  display: block; padding: 6px 12px; border-radius: 999px; color: var(--ink);
  text-decoration: none; font-weight: 500; font-size: 0.95rem;
}
.primary-nav a:hover { background: var(--paper); color: var(--ink); }
.primary-nav .current-menu-item > a,
.primary-nav .current-cat > a,
.primary-nav a[aria-current="page"] { background: var(--ink); color: var(--paper); }
.header-search { display: flex; }
.header-search input[type="search"] {
  width: 180px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--paper); color: var(--ink); font: inherit; font-size: 0.92rem;
}
.header-search button { display: none; }
@media (max-width: 760px) {
  .primary-nav { margin-left: 0; width: 100%; overflow-x: auto; scrollbar-width: none; order: 3; }
  .primary-nav ul { flex-wrap: nowrap; }
  .primary-nav a { white-space: nowrap; background: var(--paper); }
  .header-search { margin-left: auto; }
  .header-search input[type="search"] { width: 140px; }
}

main { min-height: 60vh; }

/* ---------- Footer ---------- */
.site-footer { margin-top: 72px; border-top: 1px solid var(--line); background: var(--surface); font-size: var(--step--1); color: var(--ink-soft); }
.site-footer .foot { display: grid; gap: 20px; padding-block: 36px; }
@media (min-width: 760px) { .site-footer .foot { grid-template-columns: 1.2fr 1fr; } .site-footer .disclaimer { grid-column: 1 / -1; } }
.site-footer p { margin: 10px 0 0; }
.foot-links { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.foot-links a { color: var(--ink); }
.site-footer .disclaimer { margin: 0; padding-top: 16px; border-top: 1px solid var(--line); }

/* ---------- Breadcrumb ---------- */
.crumbs, .rank-math-breadcrumb { font-size: var(--step--1); color: var(--ink-soft); }
.crumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.crumbs li + li::before { content: '/'; margin-right: 4px; opacity: 0.5; }
.crumbs a, .rank-math-breadcrumb a { color: var(--ink-soft); }
.rank-math-breadcrumb p { margin: 0; }
.rank-math-breadcrumb .separator { opacity: 0.5; margin: 0 4px; }

/* ---------- Page heads ---------- */
.page { padding-top: 20px; }
.page-head { margin: 16px 0 24px; max-width: var(--measure); }
.page-head h1 + p { margin-top: 12px; }
.updated { color: var(--ink-soft); margin: 0; }
.updated time { color: var(--ink); font-weight: 600; }
.lead { font-size: var(--step-1); color: var(--ink-soft); line-height: 1.5; margin: 0; }
.byline { margin: 12px 0 0; color: var(--ink-soft); font-size: var(--step--1); }
.byline a { color: var(--ink); font-weight: 600; }

/* ---------- Ticket ---------- */
.cv-ticket {
  --stub: 40px;
  container-type: inline-size;
  position: relative;
  display: grid;
  grid-template-columns: var(--stub) 1fr auto;
  align-items: center;
  background: var(--ticket);
  color: var(--ticket-ink);
  border-radius: var(--radius-ticket);
  -webkit-mask:
    radial-gradient(circle 9px at var(--stub) 0, #0000 98%, #000) top / 100% 51% no-repeat,
    radial-gradient(circle 9px at var(--stub) 100%, #0000 98%, #000) bottom / 100% 51% no-repeat;
  mask:
    radial-gradient(circle 9px at var(--stub) 0, #0000 98%, #000) top / 100% 51% no-repeat,
    radial-gradient(circle 9px at var(--stub) 100%, #0000 98%, #000) bottom / 100% 51% no-repeat;
}
.cv-ticket.is-weak { background: var(--ticket-pale); }
.cv-stub {
  align-self: stretch; display: grid; place-items: center;
  writing-mode: vertical-rl; transform: rotate(180deg);
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.02em;
  border-left: 2px dashed rgba(59, 47, 0, 0.35); padding-block: 10px; white-space: nowrap;
}
.cv-ticket.is-tested .cv-stub { color: #0b6b3c; }
.cv-body { padding: 14px 12px 14px 16px; min-width: 0; }
.cv-body p { margin: 0; }
.cv-game { font-size: 0.8rem; font-weight: 600; margin-bottom: 2px !important; }
.cv-game a { color: inherit; }
.cv-code {
  font-family: var(--font-code); font-weight: 700; font-size: clamp(0.88rem, 3.9cqi, 1.35rem);
  letter-spacing: 0.01em; line-height: 1.3; overflow-wrap: anywhere;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.cv-new { font-family: var(--font-body); font-size: 0.7rem; font-weight: 600; background: var(--ticket-ink); color: var(--ticket); padding: 1px 8px; border-radius: 999px; }
.cv-reward { font-weight: 500; margin-top: 2px !important; }
.cv-meta, .cv-note { font-size: 0.78rem; opacity: 0.8; margin-top: 4px !important; }
.cv-copy {
  margin-right: 14px; display: inline-flex; align-items: center; gap: 8px; border: 0;
  border-radius: var(--radius-ui); background: #1b2340; color: #fff;
  font: 600 0.92rem/1 var(--font-body); padding: 12px 16px; cursor: pointer; min-height: 44px; white-space: nowrap;
}
.cv-copy:hover { background: #2f4bff; }
.cv-copy:active { transform: translateY(1px); }
.cv-copy.is-copied { background: #0f9d58; }
@media (max-width: 480px) {
  .cv-body { padding: 12px 8px 12px 14px; }
  .cv-copy { margin-right: 10px; padding: 10px 12px; gap: 6px; }
}
.ticket-list { display: grid; gap: 12px; max-width: 760px; }
.hint { font-size: var(--step--1); color: var(--ink-soft); max-width: 760px; margin: 14px 0 0; }
.empty { padding: 20px; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius-ui); max-width: 760px; }

/* ---------- Redeem steps ---------- */
.redeem { margin-top: 48px; max-width: var(--measure); }
.steps { counter-reset: step; list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 2px; }
.steps li { counter-increment: step; position: relative; padding: 14px 16px 14px 60px; background: var(--surface); border-radius: 4px; }
.steps li:first-child { border-radius: var(--radius-ui) var(--radius-ui) 4px 4px; }
.steps li:last-child { border-radius: 4px 4px var(--radius-ui) var(--radius-ui); }
.steps li::before {
  content: counter(step); position: absolute; left: 16px; top: 12px; width: 30px; height: 30px;
  display: grid; place-items: center; border-radius: 50%; background: #2f4bff; color: #fff;
  font-family: var(--font-display); font-weight: 800; line-height: 1; padding-top: 2px;
}

/* ---------- Expired ---------- */
.expired { margin-top: 48px; max-width: var(--measure); }
.expired > p { color: var(--ink-soft); margin: 8px 0 14px; }
.expired ul { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; }
.expired li { background: var(--dead); color: var(--dead-ink); border-radius: 8px; padding: 8px 12px; display: grid; font-size: var(--step--1); }
.expired s { font-family: var(--font-code); font-weight: 700; font-size: 0.9rem; overflow-wrap: anywhere; }

/* ---------- FAQ ---------- */
.cv-faq { max-width: var(--measure); margin-top: 48px; }
.cv-faq h2 { margin-bottom: 12px; }
.cv-faq details { border-bottom: 1px solid var(--line); }
.cv-faq summary { cursor: pointer; padding: 16px 32px 16px 0; font-weight: 600; list-style: none; position: relative; }
.cv-faq summary::-webkit-details-marker { display: none; }
.cv-faq summary::after { content: '+'; position: absolute; right: 4px; top: 12px; font-size: 1.4rem; font-weight: 400; color: var(--cobalt); }
.cv-faq details[open] summary::after { content: '–'; }
.cv-faq details p { margin: 0 0 16px; color: var(--ink-soft); }

/* ---------- Post list ---------- */
.post-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.post-list li { border-bottom: 1px solid var(--line); }
.post-list a { display: grid; gap: 4px; padding: 18px 4px; text-decoration: none; color: var(--ink); }
.post-list a:hover .pl-title { color: var(--cobalt); text-decoration: underline; text-underline-offset: 0.18em; }
.pl-title { font-family: var(--font-display); font-weight: 700; font-size: var(--step-1); line-height: 1.25; }
.pl-desc { color: var(--ink-soft); font-size: 0.95rem; max-width: var(--measure); }
.pl-info { display: flex; gap: 12px; font-size: var(--step--1); color: var(--ink-soft); }
.pl-info strong { font-weight: 600; color: var(--ink); }

/* ---------- Game grid ---------- */
.games { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.games a {
  display: grid; grid-template-columns: 52px 1fr; grid-template-rows: auto auto; column-gap: 14px; align-items: center;
  padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-ui);
  text-decoration: none; color: var(--ink);
}
.games a:hover { border-color: var(--cobalt); }
.games a:hover .g-name { color: var(--cobalt); }
.mark {
  grid-row: span 2; width: 52px; height: 52px; display: grid; place-items: center;
  background: var(--c, #2f4bff); color: #fff; font-family: var(--font-display); font-weight: 800; font-size: 1.15rem;
  border-radius: 8px; box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.22); padding-bottom: 3px;
}
.g-name { font-family: var(--font-display); font-weight: 700; font-size: var(--step-1); line-height: 1.2; }
.g-meta { font-size: var(--step--1); color: var(--ink-soft); }

/* ---------- Sections ---------- */
.block { margin-top: 56px; }
.block > h2 { margin-bottom: 16px; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 20px; margin-bottom: 16px; }
.section-head h2 { margin: 0; }
.section-head a { font-weight: 600; }
.related, .other-games { margin-top: 48px; }
.related h2, .other-games h2 { margin-bottom: 12px; }
.code-cta { max-width: var(--measure); background: var(--ticket); color: var(--ticket-ink); border-radius: var(--radius-ui); padding: 12px 16px; margin-bottom: 28px; }
.code-cta p { margin: 0; }
.code-cta a { color: var(--ticket-ink); font-weight: 600; }
.sources { margin-top: 48px; max-width: var(--measure); font-size: var(--step--1); }
.sources h2 { font-size: var(--step-1); }
.sources ul { padding-left: 1.2em; margin: 10px 0 0; }
.sources a { overflow-wrap: anywhere; }

/* ---------- Home ---------- */
.hero { background: #2f4bff; color: #fff; overflow: hidden; }
.hero-grid { display: grid; gap: 32px; padding-block: 40px 44px; align-items: center; }
@media (min-width: 880px) { .hero-grid { grid-template-columns: 1.05fr 1fr; padding-block: 64px; } }
.hero h1 { font-size: clamp(2.1rem, 7vw, 3.4rem); line-height: 1.02; max-width: 12ch; }
.hero .lead { color: #fff; opacity: 0.92; max-width: 36ch; margin-top: 18px; }
.stamp { margin: 22px 0 0; font-size: var(--step--1); padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, 0.25); max-width: 44ch; }
.stamp strong, .stamp time { font-weight: 600; }
.hero-tickets { display: grid; gap: 12px; }
@media (min-width: 880px) {
  .hero-tickets > :nth-child(1) { transform: rotate(-2deg) translateX(-6px); }
  .hero-tickets > :nth-child(2) { transform: rotate(1.2deg) translateX(10px); }
  .hero-tickets > :nth-child(3) { transform: rotate(-0.6deg); }
}
.split { display: grid; gap: 48px; }
@media (min-width: 880px) { .split { grid-template-columns: 1.6fr 1fr; } }
.topics ul { list-style: none; margin: 0; padding: 0; }
.topics li { padding: 14px 0; border-bottom: 1px solid var(--line); }
.topics li:first-child { border-top: 1px solid var(--line); }
.topics a { font-weight: 600; }
.topics p { margin: 4px 0 0; font-size: var(--step--1); color: var(--ink-soft); }

/* ---------- Game index (/code/) ---------- */
.game-filter { width: 100%; max-width: 420px; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius-ui); background: var(--surface); color: var(--ink); font: inherit; margin-bottom: 20px; }
.game-filter-empty { display: none; }

/* ---------- Entry content ---------- */
.prose { max-width: var(--measure); }
.prose > * + * { margin-top: 1em; }
.prose > :first-child { margin-top: 0; }
.prose h2 { margin-top: 2.2em; font-size: var(--step-2); }
.prose h3 { margin-top: 1.8em; }
.prose p, .prose li { text-wrap: pretty; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: 0.35em; }
.prose strong { font-weight: 600; }
.prose code { font-family: var(--font-code); font-size: 0.92em; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 0.05em 0.35em; }
.prose table { width: 100%; border-collapse: collapse; font-size: var(--step--1); display: block; overflow-x: auto; }
.prose th, .prose td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose th { font-weight: 600; background: var(--surface); }
.prose blockquote { margin-left: 0; padding: 12px 16px; border-left: 4px solid var(--ticket); background: var(--surface); border-radius: 0 var(--radius-ui) var(--radius-ui) 0; }
.prose blockquote > :first-child { margin-top: 0; }
.prose blockquote > :last-child { margin-bottom: 0; }
.prose img { border-radius: var(--radius-ui); }

.pagination { margin-top: 32px; display: flex; gap: 8px; flex-wrap: wrap; }
.pagination .page-numbers { padding: 6px 12px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.pagination .current { background: var(--ink); color: var(--paper); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .hero-tickets > * { transform: none !important; }
}
