:root {
  color-scheme: light;
  --bg: #fbf7f4;
  --surface: #ffffff;
  --surface-2: #f7f0eb;
  --text: #1d1a18;
  --muted: #6b625c;
  --border: #eadfd7;
  --accent: #b3261e;
  --accent-soft: #fbe7e4;
  --on-accent: #ffffff;
  --prize: #c62828;
  --hit: #ffe28a;
  --notice-bg: #fff4dd;
  --notice-border: #eec26a;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(70 30 20 / 6%), 0 6px 20px rgb(70 30 20 / 5%);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font);
}

a {
  color: var(--accent);
  text-underline-offset: 2px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.wrap {
  max-width: 1040px;
  margin-inline: auto;
  padding-inline: 16px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 8px;
  top: 8px;
  transform: translateY(-200%);
  padding: 8px 12px;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 8px;
  z-index: 10;
}

.skip-link:focus {
  transform: none;
}

.muted,
.meta {
  color: var(--muted);
}

/* Header */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-block: 12px 4px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 1.125rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #ff8a7a, #b3261e 70%);
}

.nav-scroll {
  position: relative;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-block: 6px 8px;
  scrollbar-width: none;
}

.nav-scroll::-webkit-scrollbar {
  display: none;
}

.nav-scroll a {
  flex: none;
  padding: 7px 12px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.9375rem;
  text-decoration: none;
  white-space: nowrap;
}

.nav-scroll a:hover {
  color: var(--text);
  background: var(--surface-2);
}

.nav-scroll a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* Nội dung */

main {
  padding-block: 16px 56px;
}

h1 {
  margin: 8px 0 10px;
  font-size: clamp(1.5rem, 1.15rem + 1.6vw, 2.125rem);
  line-height: 1.2;
  letter-spacing: -0.015em;
}

h2 {
  margin: 36px 0 10px;
  font-size: 1.25rem;
  line-height: 1.3;
}

h2 a {
  color: inherit;
  text-decoration-color: var(--border);
}

h2 a:hover {
  color: var(--accent);
}

h3.sub {
  margin: 20px 0 8px;
  font-size: 1rem;
}

.lead {
  max-width: 70ch;
  margin: 0 0 16px;
  font-size: 1.0625rem;
}

.meta {
  margin: 6px 0 10px;
  font-size: 0.875rem;
}

.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 0 4px;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.8125rem;
}

.breadcrumbs li + li::before {
  content: "›";
  margin-right: 4px;
}

.breadcrumbs a {
  color: inherit;
}

.notice {
  margin: 12px 0;
  padding: 10px 14px;
  border: 1px solid var(--notice-border);
  border-radius: var(--radius);
  background: var(--notice-bg);
  font-size: 0.9375rem;
}

.notice p {
  margin: 0;
}

.notice p + p {
  margin-top: 4px;
}

.prose {
  max-width: 72ch;
}

.prose ul {
  padding-left: 1.25em;
}

.prose li + li {
  margin-top: 6px;
}

.day-title {
  margin: 0 0 8px;
  font-weight: 600;
}

.region-block + .region-block {
  margin-top: 8px;
}

/* Bảng kết quả */

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.table-scroll.narrow {
  max-width: 640px;
}

.kq {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-variant-numeric: tabular-nums;
}

.kq th,
.kq td {
  padding: 7px 6px;
  border-bottom: 1px solid var(--border);
  text-align: center;
  vertical-align: middle;
}

.kq tbody tr:last-child > * {
  border-bottom: 0;
}

.kq tbody tr:nth-child(even) {
  background: #fcf9f7;
}

.kq-box.north,
.kq-box.south.cols-1 {
  max-width: 600px;
}

.kq-box.south {
  max-width: 860px;
}

.kq col.c-label {
  width: 48px;
}

.kq tbody th {
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
}

.kq thead th {
  background: var(--accent-soft);
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.3;
}

.kq thead th.p-head {
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
}

.kq thead th a {
  color: var(--accent);
  text-decoration: none;
}

.kq thead th a:hover {
  text-decoration: underline;
}

.kq abbr {
  text-decoration: none;
}

.kq td + td {
  border-left: 1px solid var(--border);
}

.n {
  display: block;
  padding: 1px 2px;
  border-radius: 6px;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.n.hit {
  background: var(--hit);
  box-shadow: inset 0 0 0 2px #e0a800;
}

.kq .row-db .n {
  color: var(--prize);
  font-size: 1.375rem;
  font-weight: 800;
}

.kq-north .row-db .n {
  font-size: 1.625rem;
}

.kq-south .row-g8 .n {
  color: var(--prize);
  font-size: 1.25rem;
  font-weight: 700;
}

.kq-north .nums {
  display: grid;
  grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr));
  gap: 2px 8px;
}

.source-note {
  margin: 8px 0 0;
  font-size: 0.875rem;
}

.source-note p {
  margin: 2px 0 0;
}

.pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
  font-weight: 500;
}

/* Vietlott */

.balls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 8px 0 0;
}

.ball {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #ff7a6b, #c62828 72%);
  color: #fff;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 -2px 0 rgb(0 0 0 / 12%);
}

.ball.bonus {
  background: radial-gradient(circle at 32% 28%, #ffe083, #e0a100 72%);
  color: #3b2a00;
}

.ball-sep {
  color: var(--muted);
}

.balls.lg {
  gap: 8px;
  margin-block: 12px 4px;
}

.balls.lg .ball {
  width: 50px;
  height: 50px;
  font-size: 1.25rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.data-table th,
.data-table td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.data-table thead th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}

.data-table tbody th {
  font-weight: 600;
  white-space: nowrap;
}

.data-table tbody tr:last-child > * {
  border-bottom: 0;
}

.data-table .num {
  text-align: right;
  white-space: nowrap;
}

.data-table .balls {
  margin: 0;
  gap: 4px;
}

.data-table .ball {
  width: 30px;
  height: 30px;
  font-size: 0.875rem;
}

.row-note {
  display: block;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 400;
}

/* Thẻ */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin-block: 12px 8px;
}

.card {
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.card-title a {
  color: var(--text);
  text-decoration: none;
}

.card-title a:hover {
  text-decoration: underline;
}

.card-label {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

/* Liên kết */

.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.link-grid a {
  display: block;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
}

.link-grid a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Dò vé số */

.tool {
  display: grid;
  gap: 14px;
  max-width: 600px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.tool .meta {
  margin: -6px 0 0;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.field label {
  font-size: 0.9375rem;
  font-weight: 600;
}

.field input,
.field select {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

#so {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}

.btn {
  justify-self: start;
  min-height: 44px;
  padding: 10px 20px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.tool-result {
  max-width: 640px;
  margin-top: 8px;
}

.match-list {
  margin: 0 0 12px;
  padding-left: 1.25em;
}

.match-list li + li {
  margin-top: 4px;
}

/* Footer */

.site-footer {
  padding-block: 24px 32px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.875rem;
}

.site-footer p {
  max-width: 80ch;
  margin: 8px 0 0;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
}

.footer-links a {
  color: var(--text);
}

@media (max-width: 520px) {
  .kq th,
  .kq td {
    padding: 6px 3px;
  }

  .kq col.c-label {
    width: 36px;
  }

  .kq thead th {
    font-size: 0.8125rem;
  }

  .n {
    font-size: 1rem;
    letter-spacing: 0;
  }

  .kq .row-db .n {
    font-size: 1.125rem;
  }

  .kq-north .row-db .n {
    font-size: 1.375rem;
  }

  .kq-south .row-g8 .n {
    font-size: 1.0625rem;
  }

  .kq-north .nums {
    gap: 2px 4px;
  }

  .kq-south.cols-4 .n {
    font-size: 0.9375rem;
  }

  .data-table th,
  .data-table td {
    padding: 8px 10px;
  }

  .balls.lg {
    gap: 6px;
  }

  .balls.lg .ball {
    width: 42px;
    height: 42px;
    font-size: 1.0625rem;
  }

  .data-table .balls {
    gap: 3px;
  }

  .data-table .ball {
    width: 27px;
    height: 27px;
    font-size: 0.8125rem;
  }

  .field-row {
    grid-template-columns: minmax(0, 1fr);
  }
}
