/* =========================================================
   Mawinbet — mawinhub365.co (static rebuild for Cloudflare Pages)
   ธีม: ดำ-ทอง ตามแบรนด์ (#151e25 / #fcd535) | ฟอนต์: Kanit
   ========================================================= */

:root {
  --bg: #151e25;
  --bg-alt: #1a242e;
  --panel: #1f2a35;
  --panel-2: #243240;
  --line: #2d3a48;
  --gold: #fcd535;
  --gold-2: #fbbf24;
  --gold-3: #ffb804;
  --gold-dark: #c9a900;
  --text: #fafafa;
  --text-2: #cdd3da;
  --muted: #9aa5b1;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --grad-gold: linear-gradient(135deg, #fcd535 0%, #ffb804 100%);
  --header-h: 72px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

/* เมนู topbar เลื่อนไป section แล้วหัวข้อไม่โดน sticky header บัง */
main [id] { scroll-margin-top: 92px; }

body {
  font-family: 'Kanit', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 64px; /* ที่ว่างให้ float CTA บนมือถือ */
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--gold); text-decoration: none; transition: color .2s; }
a:hover { color: #fff; }

.container { width: min(1180px, 100% - 40px); margin-inline: auto; }
.container.narrow { width: min(860px, 100% - 40px); }
.center { text-align: center; }

/* ---------- ปุ่ม ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform .15s, box-shadow .2s, filter .2s;
  white-space: nowrap;
}
.btn-gold {
  background: var(--grad-gold);
  color: #1a1a1a;
  box-shadow: 0 6px 18px rgba(252, 213, 53, .25);
}
.btn-gold:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(252, 213, 53, .35); color: #1a1a1a; }
.btn-outline {
  background: transparent;
  color: var(--gold);
  border-color: var(--gold);
}
.btn-outline:hover { background: rgba(252, 213, 53, .1); color: var(--gold); transform: translateY(-2px); }
.btn-ghost {
  background: var(--panel);
  color: var(--text);
  border-color: var(--line);
}
.btn-ghost:hover { border-color: var(--gold); color: var(--gold); }
.btn-lg { padding: 14px 34px; font-size: 1.1rem; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(21, 30, 37, .92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: var(--header-h);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { color: var(--text); }
.brand img { width: 44px; height: 44px; border-radius: 12px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 1.15rem; font-weight: 700; color: var(--gold); }
.brand-text small { font-size: .8rem; color: var(--muted); }

.main-nav { flex: 1; }
.nav-list {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
}
.nav-list > li { position: relative; }
.nav-list > li > a {
  display: block;
  padding: 10px 13px;
  color: var(--text-2);
  font-weight: 500;
  font-size: .95rem;
  border-radius: var(--radius-sm);
}
.nav-list > li > a:hover { color: var(--gold); background: rgba(252, 213, 53, .08); }

/* dropdown */
.sub-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 260px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  list-style: none;
  padding: 8px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: all .2s ease;
  z-index: 50;
}
.has-sub:hover > .sub-menu,
.has-sub:focus-within > .sub-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.sub-menu a {
  display: block;
  padding: 9px 12px;
  color: var(--text-2);
  font-size: .9rem;
  border-radius: 8px;
}
.sub-menu a:hover { background: rgba(252, 213, 53, .1); color: var(--gold); }

.header-cta { display: flex; gap: 10px; }

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.nav-toggle span { display: block; width: 22px; height: 2px; background: var(--gold); margin-inline: auto; transition: all .25s; }
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Hero ---------- */
.hero {
  padding: 28px 0 40px;
  background:
    radial-gradient(1200px 500px at 70% -10%, rgba(252, 213, 53, .12), transparent 60%),
    radial-gradient(900px 400px at 10% 110%, rgba(251, 191, 36, .07), transparent 60%);
}
.awards {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.awards img { height: 72px; border-radius: 10px; border: 1px solid var(--line); }

.hero-grid {
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: 36px;
  align-items: center;
}
.hero-text h1 {
  font-size: clamp(1.6rem, 3.4vw, 2.5rem);
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 16px;
  background: linear-gradient(180deg, #fff 55%, #fcd535 130%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-text p { color: var(--text-2); margin-bottom: 24px; }
.hero-text p strong { color: var(--gold); }
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; }
.hero-media img {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

/* ---------- Providers ---------- */
.providers { padding: 8px 0 32px; }
.provider-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}
.provider-grid img {
  width: 100%;
  aspect-ratio: 269 / 440;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  transition: transform .25s, border-color .25s;
}
.provider-grid img:hover { transform: translateY(-6px); border-color: var(--gold); }

/* ---------- Quick links ---------- */
.quicklinks { padding: 8px 0 44px; }
.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}
.quick-card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.quick-card img { width: 100%; transition: transform .3s; }
.quick-card:hover img { transform: scale(1.05); }
.quick-card span {
  position: absolute;
  inset: auto 0 0 0;
  padding: 10px;
  text-align: center;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(180deg, transparent, rgba(10, 14, 18, .88));
}

/* ---------- Sections ---------- */
.section { padding: 64px 0; }
.section-alt { background: var(--bg-alt); }

.section-title {
  position: relative;
  font-size: clamp(1.35rem, 2.6vw, 1.9rem);
  font-weight: 700;
  margin-bottom: 18px;
  padding-left: 16px;
}
.section-title::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 5px;
  border-radius: 4px;
  background: var(--grad-gold);
}
.section-title.center { padding-left: 0; }
.section-title.center::before {
  left: 50%;
  transform: translateX(-50%);
  top: -14px;
  bottom: auto;
  width: 56px;
  height: 5px;
}
.section-sub { color: var(--muted); margin-bottom: 34px; font-size: 1.02rem; }
.section-sub.center { max-width: 760px; margin-inline: auto; }

.two-col {
  display: grid;
  grid-template-columns: .9fr 1.1fr;
  gap: 36px;
  align-items: center;
}
.two-col.reverse .col-media { order: 2; }
.col-media img { width: 100%; border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); }
.col-text p { color: var(--text-2); margin-bottom: 14px; }

.subsection-title { font-size: 1.25rem; margin: 10px 0 4px; color: var(--gold); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ---------- Lotto cards ---------- */
.lotto-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
}
.lotto-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform .25s, border-color .25s;
}
.lotto-card:hover { transform: translateY(-6px); border-color: var(--gold-2); }
.lotto-card img { width: 100%; aspect-ratio: 1024 / 584; object-fit: cover; }
.lotto-card h3 { font-size: 1.15rem; padding: 16px 20px 6px; color: var(--gold); }
.lotto-card ul { list-style: none; padding: 0 20px; flex: 1; }
.lotto-card ul li {
  position: relative;
  padding: 4px 0 4px 20px;
  color: var(--text-2);
  font-size: .95rem;
}
.lotto-card ul li::before {
  content: "•";
  position: absolute;
  left: 4px;
  color: var(--gold);
}
.lotto-links { padding: 10px 20px 20px; }
.lotto-links .more { color: var(--muted); font-size: .9rem; margin-bottom: 6px; }
.lotto-links a { display: block; font-size: .92rem; padding: 2px 0; }

/* ---------- Game cards ---------- */
.game-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
}
.game-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  color: var(--text);
  transition: transform .25s, border-color .25s;
}
.game-card:hover { transform: translateY(-6px); border-color: var(--gold-2); color: var(--text); }
.game-card img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.game-body { padding: 18px 20px 22px; }
.game-body h3 { font-size: 1.05rem; color: var(--gold); margin-bottom: 8px; }
.game-body p { color: var(--text-2); font-size: .93rem; }

/* ---------- Promotions ---------- */
.promo-slider {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 46%;
  gap: 16px;
  overflow-x: auto;
  padding: 6px 4px 18px;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
  scrollbar-color: var(--panel-2) transparent;
  margin-bottom: 26px;
}
.promo-slider a { scroll-snap-align: center; }
.promo-slider img {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  transition: border-color .25s, transform .25s;
}
.promo-slider a:hover img { border-color: var(--gold); transform: translateY(-4px); }

.promo-lead { color: var(--text-2); max-width: 820px; margin: 0 auto 22px; text-align: center; }
.promo-lead strong { color: var(--gold); }

.check-list {
  list-style: none;
  max-width: 860px;
  margin: 0 auto 30px;
  display: grid;
  gap: 10px;
}
.check-list li {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 16px 12px 46px;
  color: var(--text-2);
  font-size: .95rem;
}
.check-list li::before {
  content: "✓";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  background: var(--grad-gold);
  color: #1a1a1a;
  font-weight: 700;
  font-size: .8rem;
  border-radius: 50%;
}

/* ---------- Steps ---------- */
.steps { list-style: none; display: grid; gap: 14px; margin-top: 6px; }
.steps li { display: flex; gap: 14px; align-items: flex-start; }
.steps li > span {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: var(--grad-gold);
  color: #1a1a1a;
  font-weight: 700;
  border-radius: 50%;
}
.steps li > div { color: var(--text-2); padding-top: 3px; }

/* ---------- Rates ---------- */
.rate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin: 18px 0;
}
.rate-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  transition: border-color .2s;
}
.rate-card:hover { border-color: var(--gold); }
.rate-label { display: block; color: var(--muted); font-size: .9rem; margin-bottom: 6px; }
.rate-value { color: var(--text); }
.rate-value b { color: var(--gold); font-size: 1.6rem; font-weight: 700; }
.note {
  border-left: 4px solid var(--gold);
  background: rgba(252, 213, 53, .07);
  padding: 12px 16px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: .95rem;
  margin-bottom: 18px;
}

/* ---------- Results (ดึงจาก API) ---------- */
.results-head {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.results-updated { color: var(--muted); font-size: .92rem; }
.results-updated.ok { color: #4ade80; }
.results-updated.err { color: #f87171; }
.results-refresh {
  font-family: inherit;
  font-size: .88rem;
  font-weight: 500;
  color: var(--gold);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 16px;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.results-refresh:hover { border-color: var(--gold); background: rgba(252, 213, 53, .08); }
.results-refresh.busy { opacity: .5; pointer-events: none; }

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 18px;
  margin-bottom: 16px;
}
.result-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  color: var(--text);
  transition: transform .25s, border-color .25s;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.result-card:hover { transform: translateY(-5px); border-color: var(--gold); color: var(--text); }
.result-round {
  display: inline-block;
  align-self: center;
  font-size: .78rem;
  font-weight: 500;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 12px;
  margin-bottom: 2px;
}
.result-card h3 { font-size: 1rem; color: var(--text-2); font-weight: 600; }
.result-digits {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: .18em;
  padding-left: .18em;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}
.result-sub { font-size: .9rem; color: var(--muted); }
.result-sub b { color: var(--text); font-size: 1.05rem; margin-left: 6px; letter-spacing: .12em; padding-left: .12em; }
.result-full { font-size: .8rem; color: var(--muted); }
.result-link { margin-top: auto; font-size: .86rem; color: var(--muted); transition: color .2s; }
.result-card:hover .result-link { color: var(--gold); }

/* สี badge ตามประเภทหวย */
.type-GOVERNMENT .result-round { color: var(--gold); border-color: rgba(252, 213, 53, .45); }
.type-STOCK .result-round { color: #38bdf8; border-color: rgba(56, 189, 248, .45); }
.type-YEEKEE .result-round { color: #f472b6; border-color: rgba(244, 114, 182, .45); }
.type-HANOI .result-round { color: #a78bfa; border-color: rgba(167, 139, 250, .45); }
.type-LAO .result-round { color: #fb923c; border-color: rgba(251, 146, 60, .45); }
.type-MALAY .result-round { color: #34d399; border-color: rgba(52, 211, 153, .45); }

/* skeleton ระหว่างโหลด */
.result-card.skeleton { animation: pulse 1.4s ease-in-out infinite; pointer-events: none; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .45; }
}

/* การ์ด error */
.result-card.error-card { border-color: rgba(248, 113, 113, .5); }
.result-card.error-card h3 { color: #f87171; }

/* ---------- Footer ---------- */
.site-footer {
  background: #10171d;
  border-top: 1px solid var(--line);
  padding: 48px 0 24px;
}
.footer-top {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1.4fr;
  gap: 34px;
  margin-bottom: 30px;
}
.footer-brand img { width: 54px; height: 54px; border-radius: 12px; margin-bottom: 12px; }
.footer-brand p { color: var(--muted); margin-bottom: 12px; }
.footer-brand a { color: var(--muted); }
.footer-brand a:hover { color: var(--gold); }
.footer-col h4 { color: var(--gold); font-size: 1.05rem; margin-bottom: 12px; }
.footer-col ul { list-style: none; display: grid; gap: 6px; }
.footer-col a { color: var(--text-2); font-size: .92rem; }
.footer-col a:hover { color: var(--gold); }
.footer-payment { text-align: center; margin-bottom: 26px; }
.footer-payment img { max-width: 420px; margin-inline: auto; border-radius: var(--radius-sm); }
.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  padding-top: 20px;
}
.footer-bottom p { color: var(--muted); font-size: .9rem; }
.footer-cta { display: flex; gap: 10px; }

/* ---------- Floating CTA + to top ---------- */
.float-cta {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  display: none;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(16, 23, 29, .96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.float-cta .btn { flex: 1; }

.to-top {
  position: fixed;
  right: 22px;
  bottom: 26px;
  z-index: 80;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--gold);
  background: var(--grad-gold);
  color: #1a1a1a;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all .3s;
}
.to-top.show { opacity: 1; visibility: visible; transform: translateY(0); }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .hero-grid { gap: 24px; }
  .lotto-grid { grid-template-columns: repeat(2, 1fr); }
  .game-grid, .blog-grid { grid-template-columns: repeat(2, 1fr); }
  .results-grid { grid-template-columns: repeat(2, 1fr); }
  .footer-top { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 860px) {
  .nav-toggle { display: flex; }
  .main-nav {
    order: 10;
    flex: 1 0 100%;
    display: none;
    padding-bottom: 16px;
  }
  .main-nav.open { display: block; }
  .nav-list { flex-direction: column; align-items: stretch; gap: 2px; }
  .nav-list > li > a { padding: 12px 14px; }
  .sub-menu {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border: none;
    background: rgba(0, 0, 0, .18);
    display: none;
    padding: 4px 0 4px 14px;
  }
  .has-sub.open > .sub-menu { display: block; }
  .header-cta { margin-left: auto; }
  .header-cta .btn { padding: 8px 16px; font-size: .9rem; }

  .float-cta { display: flex; }
  body { padding-bottom: 72px; }
  .to-top { bottom: 84px; }
}

@media (max-width: 640px) {
  .container { width: calc(100% - 32px); }
  .section { padding: 44px 0; }
  .hero { padding-top: 18px; }
  .awards img { height: 54px; }
  .hero-grid, .two-col { grid-template-columns: 1fr; gap: 24px; }
  .two-col.reverse .col-media { order: 0; }
  .provider-grid { grid-template-columns: repeat(2, 1fr); }
  .quick-grid, .lotto-grid, .game-grid, .blog-grid, .results-grid { grid-template-columns: 1fr; }
  .footer-top { grid-template-columns: 1fr; gap: 22px; }
  .footer-bottom { justify-content: center; text-align: center; }
  .hero-actions .btn { flex: 1; }
  .promo-slider { grid-auto-columns: 82%; }
}

/* ---------- Accessibility ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 4px; }

::selection { background: rgba(252, 213, 53, .35); }
