@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Thai:wght@400;500;600;700&family=Mitr:wght@400;500;600&display=swap');

:root {
  --paper: #f3efe4;
  --ink: #17202a;
  --muted: #687079;
  --red: #d9322b;
  --blue: #184b91;
  --yellow: #f3c638;
  --white: #fffdf8;
  --line: #1e2933;
  --shadow: 7px 7px 0 var(--ink);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(23,32,42,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23,32,42,.025) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  font-family: "IBM Plex Sans Thai", sans-serif;
  line-height: 1.65;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
.wrap { width: min(1180px, calc(100% - 40px)); margin-inline: auto; }
.skip { position: fixed; left: 12px; top: -80px; padding: 10px 14px; background: var(--yellow); z-index: 99; }
.skip:focus { top: 12px; }

.top-note { background: var(--ink); color: #fff; font-size: .8rem; letter-spacing: .02em; }
.top-note .wrap { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; }
.demo-flag { color: var(--yellow); font-weight: 700; }
.site-header { background: rgba(243,239,228,.95); border-bottom: 2px solid var(--ink); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(12px); }
.nav { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 28px; }
.brand { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.brand-mark { width: 45px; height: 45px; display: grid; place-items: center; color: #fff; background: var(--red); border: 2px solid var(--ink); border-radius: 50%; font-family: Mitr, sans-serif; font-weight: 600; box-shadow: 3px 3px 0 var(--ink); }
.brand-copy { line-height: 1.05; }
.brand-copy strong { display: block; font-family: Mitr, sans-serif; font-size: 1rem; }
.brand-copy span { color: var(--red); font-size: .68rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.menu { display: flex; align-items: center; gap: 26px; font-weight: 600; font-size: .92rem; }
.menu a { position: relative; }
.menu a::after { content: ""; position: absolute; left: 0; right: 100%; bottom: -5px; height: 3px; background: var(--red); transition: right .2s; }
.menu a:hover::after, .menu a[aria-current="page"]::after { right: 0; }
.menu-toggle { display: none; border: 2px solid var(--ink); background: var(--yellow); width: 43px; height: 39px; font-weight: 800; }

.hero { overflow: hidden; border-bottom: 2px solid var(--ink); }
.hero-grid { min-height: 540px; display: grid; grid-template-columns: 1.04fr .96fr; align-items: stretch; }
.hero-copy { padding: 70px 60px 64px 0; display: flex; flex-direction: column; justify-content: center; }
.eyebrow, .stamp { width: fit-content; border: 2px solid var(--ink); padding: 5px 10px; background: var(--yellow); font-size: .74rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; transform: rotate(-1.5deg); }
h1, h2, h3 { font-family: Mitr, sans-serif; line-height: 1.14; margin: 0; }
.hero h1 { font-size: clamp(3.25rem, 7vw, 6.8rem); letter-spacing: -.06em; margin: 20px 0 10px; }
.hero h1 span { color: var(--red); display: block; }
.hero-lead { font-size: 1.1rem; max-width: 570px; margin: 12px 0 28px; }
.quick-links { display: flex; gap: 10px; flex-wrap: wrap; }
.button { border: 2px solid var(--ink); padding: 12px 20px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; background: var(--white); box-shadow: 4px 4px 0 var(--ink); transition: transform .15s, box-shadow .15s; cursor: pointer; }
.button:hover { transform: translate(3px,3px); box-shadow: 1px 1px 0 var(--ink); }
.button.primary { color: #fff; background: var(--blue); }
.button.red { color: #fff; background: var(--red); }

.check-ticket { margin: 48px 0 48px 24px; align-self: center; position: relative; background: var(--white); border: 2px solid var(--ink); box-shadow: 12px 12px 0 var(--blue); transform: rotate(1deg); }
.check-ticket::before, .check-ticket::after { content: ""; position: absolute; left: -12px; width: 22px; height: 22px; background: var(--paper); border: 2px solid var(--ink); border-radius: 50%; }
.check-ticket::before { top: 32%; }
.check-ticket::after { top: 67%; }
.ticket-head { display: flex; justify-content: space-between; gap: 15px; padding: 16px 20px; background: var(--red); color: #fff; border-bottom: 2px solid var(--ink); text-transform: uppercase; font-weight: 700; font-size: .75rem; letter-spacing: .07em; }
.ticket-body { padding: 34px; }
.ticket-body h2 { font-size: clamp(1.7rem, 4vw, 2.6rem); }
.ticket-body p { color: var(--muted); margin: 8px 0 20px; }
.number-entry { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.number-entry input { width: 100%; min-width: 0; border: 2px solid var(--ink); background: #fff; padding: 13px 14px; font-size: 1.25rem; font-weight: 700; letter-spacing: .12em; outline: none; }
.number-entry input:focus { box-shadow: 0 0 0 3px rgba(243,198,56,.7); }
.check-result { min-height: 50px; margin: 18px 0 0; padding: 11px 13px; background: #e8eef6; border-left: 5px solid var(--blue); color: var(--ink) !important; }
.ticket-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 22px; margin-top: 24px; border-top: 2px dashed #8d9399; font-size: .78rem; color: var(--muted); }
.barcode { letter-spacing: -.08em; font-size: 1.35rem; color: var(--ink); transform: scaleX(.7); transform-origin: right; }

.ticker { background: var(--yellow); border-bottom: 2px solid var(--ink); overflow: hidden; white-space: nowrap; }
.ticker-track { display: flex; width: max-content; animation: ticker 24s linear infinite; }
.ticker-track span { padding: 11px 26px; font-size: .84rem; font-weight: 700; }
.ticker-track span::before { content: "✦"; margin-right: 22px; color: var(--red); }

.visual-guide { padding: 68px 0; border-bottom: 2px solid var(--ink); }
.visual-guide-grid { display: grid; grid-template-columns: 1.25fr .75fr; align-items: stretch; gap: 28px; }
.guide-image { min-height: 390px; margin: 0; overflow: hidden; border: 2px solid var(--ink); }
.guide-image img { width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; }
.guide-copy { padding: 34px; border: 2px solid var(--ink); background: var(--white); display: flex; flex-direction: column; }
.guide-copy h2 { margin: 10px 0 22px; font-size: clamp(1.8rem, 4vw, 3rem); }
.guide-links { display: grid; gap: 10px; margin-bottom: 24px; }
.guide-links a { display: grid; padding: 13px 0; border-bottom: 1px solid #bbc0c2; }
.guide-links strong { font-size: 1.05rem; }
.guide-links span { color: var(--muted); font-size: .84rem; }
.guide-copy > .button { margin-top: auto; width: fit-content; }
.nav-register { padding: 9px 16px !important; border-radius: 999px; font-weight: 700; }
@keyframes ticker { to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .ticker-track { animation: none; } * { scroll-behavior: auto !important; } }

.section { padding: 78px 0; }
.section + .section { border-top: 2px solid var(--ink); }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 30px; }
.section-index { color: var(--red); font-weight: 700; font-size: .8rem; letter-spacing: .12em; }
.section h2 { font-size: clamp(2rem, 5vw, 3.8rem); letter-spacing: -.04em; }
.section-head p { max-width: 430px; margin: 0 0 5px; color: var(--muted); }
.results-layout { display: grid; grid-template-columns: 1.45fr .55fr; gap: 22px; }
.main-result { background: var(--blue); color: #fff; border: 2px solid var(--ink); padding: 32px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.main-result::after { content: "งวดล่าสุด"; position: absolute; right: -42px; top: 30px; width: 180px; padding: 6px; color: var(--ink); background: var(--yellow); border-block: 2px solid var(--ink); text-align: center; transform: rotate(42deg); font-weight: 700; font-size: .75rem; }
.result-title { display: flex; justify-content: space-between; gap: 20px; align-items: start; }
.result-title h3 { font-size: 1.5rem; }
.result-title p { margin: 4px 0 0; opacity: .8; }
.result-number { font-family: Mitr, sans-serif; font-size: clamp(4rem, 10vw, 8.3rem); line-height: 1; letter-spacing: .08em; margin: 35px 0; color: var(--yellow); text-shadow: 4px 4px 0 rgba(0,0,0,.35); }
.prize-row { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 2px solid rgba(255,255,255,.45); }
.prize-row > div { padding: 18px 12px 0; border-right: 1px solid rgba(255,255,255,.35); }
.prize-row > div:first-child { padding-left: 0; }
.prize-row > div:last-child { border: 0; }
.prize-row small { display: block; opacity: .72; }
.prize-row strong { display: block; font-family: Mitr, sans-serif; font-size: 1.35rem; margin-top: 5px; }
.result-side { display: grid; gap: 14px; }
.mini-result { background: var(--white); border: 2px solid var(--ink); padding: 19px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; }
.mini-result:nth-child(2) { background: var(--yellow); }
.mini-result:nth-child(3) { color: #fff; background: var(--red); }
.mini-result p, .mini-result h3 { margin: 0; }
.mini-result p { color: inherit; opacity: .72; font-size: .8rem; }
.mini-number { font-family: Mitr, sans-serif; font-size: 1.9rem; letter-spacing: .04em; }
.data-note { margin-top: 22px; color: var(--muted); font-size: .84rem; }
.source-meta { margin: 24px 0 0; padding-top: 14px; border-top: 1px dashed rgba(255,255,255,.5); font-size: .78rem; opacity: .85; }
.source-meta a { color: var(--yellow); text-decoration: underline; }

.tools-grid { display: grid; grid-template-columns: 1.15fr .85fr .85fr; gap: 20px; }
.tool-card { min-height: 260px; padding: 26px; border: 2px solid var(--ink); background: var(--white); display: flex; flex-direction: column; position: relative; overflow: hidden; }
.tool-card:nth-child(2) { background: var(--yellow); }
.tool-card:nth-child(3) { background: var(--red); color: #fff; }
.tool-no { font-family: Mitr, sans-serif; font-size: 4.7rem; line-height: 1; color: rgba(23,32,42,.11); position: absolute; right: 14px; top: 7px; }
.tool-card:nth-child(3) .tool-no { color: rgba(255,255,255,.18); }
.tool-card h3 { font-size: 1.4rem; margin-top: 62px; }
.tool-card p { opacity: .78; }
.text-link { margin-top: auto; width: fit-content; border-bottom: 2px solid currentColor; font-weight: 700; }

.history-table { width: 100%; border-collapse: collapse; background: var(--white); border: 2px solid var(--ink); }
.history-table th, .history-table td { text-align: left; padding: 14px 16px; border-bottom: 1px solid #bbc0c2; }
.history-table th { background: var(--ink); color: #fff; font-size: .8rem; }
.history-table tr:last-child td { border-bottom: 0; }
.history-table strong { color: var(--red); font-family: Mitr, sans-serif; letter-spacing: .06em; }
.history-controls { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.history-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.history-tab { cursor: pointer; padding: 10px 16px; border: 1px solid var(--ink); background: transparent; color: inherit; font: inherit; font-weight: 700; }
.history-tab.active { background: var(--yellow); color: #102016; }
.history-search { display: grid; gap: 6px; min-width: min(100%, 280px); font-size: .82rem; font-weight: 700; }
.history-search input { width: 100%; padding: 11px 13px; border: 1px solid var(--ink); background: var(--white); color: inherit; font: inherit; }
.history-summary { display: flex; justify-content: space-between; align-items: end; gap: 20px; }
.history-summary p { color: var(--muted); }
.history-scroll { overflow-x: auto; }
.history-pagination { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 24px; }
.history-pagination .button { padding: 9px 18px; }
.history-pagination .button:disabled { cursor: not-allowed; opacity: .35; transform: none; }

.article-grid { display: grid; grid-template-columns: 1.35fr .65fr; border: 2px solid var(--ink); background: var(--white); }
.featured-article { padding: 36px; min-height: 320px; display: flex; flex-direction: column; background: var(--blue); color: #fff; }
.featured-article h3 { font-size: clamp(1.8rem, 4vw, 3rem); margin: 30px 0 10px; }
.featured-article .text-link { color: var(--yellow); }
.article-list article { padding: 23px; border-bottom: 2px solid var(--ink); }
.article-list article:last-child { border: 0; }
.article-list h3 { font-size: 1.05rem; }
.article-list p { margin: 4px 0 0; color: var(--muted); font-size: .85rem; }

.page-hero { padding: 65px 0 55px; border-bottom: 2px solid var(--ink); background: linear-gradient(105deg, var(--yellow) 0 38%, transparent 38%); }
.breadcrumbs { font-size: .8rem; margin-bottom: 20px; }
.page-hero h1 { font-size: clamp(2.6rem, 7vw, 5.8rem); letter-spacing: -.05em; max-width: 900px; }
.page-hero p { font-size: 1.05rem; max-width: 650px; }
.content-grid { display: grid; grid-template-columns: minmax(0,1fr) 280px; gap: 36px; }
.content-card { background: var(--white); border: 2px solid var(--ink); padding: 30px; }
.content-card + .content-card { margin-top: 20px; }
.content-card h2 { font-size: clamp(1.6rem, 4vw, 2.4rem); margin-bottom: 14px; }
.content-card h3 { margin-top: 22px; }
.side-menu { position: sticky; top: 106px; align-self: start; border: 2px solid var(--ink); background: var(--white); }
.side-menu strong { display: block; padding: 14px 17px; background: var(--red); color: #fff; }
.side-menu a { display: block; padding: 11px 17px; border-top: 1px solid #b5babd; }
.side-menu a:hover { background: var(--yellow); }
.stat-bars { display: grid; gap: 14px; margin-top: 24px; }
.stat-line { display: grid; grid-template-columns: 45px 1fr 35px; align-items: center; gap: 12px; font-weight: 700; }
.bar { height: 17px; border: 2px solid var(--ink); background: #e5e2da; }
.bar i { display: block; height: 100%; background: var(--blue); }

.footer { border-top: 2px solid var(--ink); background: var(--ink); color: #fff; padding: 45px 0 24px; }
.footer-grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: 50px; }
.footer h2 { color: var(--yellow); font-size: 1.8rem; }
.footer p { color: #c4c9cd; }
.footer-links { display: grid; grid-template-columns: repeat(2,1fr); gap: 7px 18px; }
.footer-links a:hover { color: var(--yellow); }
.legal { border-top: 1px solid #576069; margin-top: 30px; padding-top: 20px; font-size: .78rem; color: #aeb6bc; display: flex; justify-content: space-between; gap: 20px; }

@media (max-width: 900px) {
  .menu-toggle { display: block; }
  .menu { display: none; position: absolute; left: 0; right: 0; top: 76px; padding: 18px 20px; background: var(--paper); border-bottom: 2px solid var(--ink); flex-direction: column; align-items: stretch; gap: 4px; }
  .menu.open { display: flex; }
  .menu a { padding: 8px; }
  .hero-grid { grid-template-columns: 1fr; }
  .visual-guide-grid { grid-template-columns: 1fr; }
  .hero-copy { padding: 56px 0 10px; }
  .check-ticket { margin: 25px 10px 55px 0; transform: rotate(.5deg); }
  .results-layout, .content-grid { grid-template-columns: 1fr; }
  .result-side { grid-template-columns: repeat(3,1fr); }
  .mini-result { grid-template-columns: 1fr; }
  .tools-grid { grid-template-columns: 1fr 1fr; }
  .tool-card:first-child { grid-column: span 2; }
  .side-menu { position: static; }
}

@media (max-width: 620px) {
  .wrap { width: min(100% - 24px, 1180px); }
  .top-note .wrap span:last-child { display: none; }
  .brand-copy span { display: none; }
  .hero-copy { padding-top: 42px; }
  .hero h1 { font-size: clamp(3rem, 16vw, 4.5rem); }
  .ticket-body { padding: 25px 20px; }
  .number-entry { grid-template-columns: 1fr; }
  .number-entry .button { width: 100%; }
  .section { padding: 55px 0; }
  .visual-guide { padding: 42px 0; }
  .guide-image { min-height: 220px; }
  .guide-copy { padding: 24px 20px; }
  .section-head { display: block; }
  .section-head p { margin-top: 10px; }
  .result-title { display: block; }
  .main-result { padding: 25px 20px; }
  .result-number { font-size: 17vw; }
  .prize-row { grid-template-columns: 1fr; }
  .prize-row > div { border-right: 0; border-bottom: 1px solid rgba(255,255,255,.3); padding: 13px 0; }
  .result-side, .tools-grid, .article-grid, .footer-grid { grid-template-columns: 1fr; }
  .tool-card:first-child { grid-column: auto; }
  .tool-card { min-height: 220px; }
  .history-table { font-size: .8rem; }
  .history-table th, .history-table td { padding: 10px 8px; }
  .history-controls, .history-summary { display: grid; align-items: stretch; }
  .history-search { min-width: 0; }
  .article-grid { display: block; }
  .footer-links { grid-template-columns: 1fr; }
  .legal { display: block; }
}
