/* BALLTHAI.IN.TH — shared stylesheet (mobile first) */
:root {
  --navy: #1B2A4A;
  --navy-deep: #14203A;
  --navy-hover: #2A3E6B;
  --red: #E31E24;
  --red-ink: #C4161C;
  --bg: #F4F6FA;
  --card: #FFFFFF;
  --ink: #1B2A4A;
  --text: #2B3550;
  --muted: #5B6785;
  --line: #D9E0EC;
  --zebra: #F3F5FA;
  --font: "IBM Plex Sans Thai", "Sarabun", "Noto Sans Thai", "Leelawadee UI", Tahoma, system-ui, sans-serif;
  --radius: 10px;
  --pad: 16px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}
img { max-width: 100%; height: auto; }
a { color: var(--red-ink); }
a:hover { color: var(--red); }
:focus-visible { outline: 3px solid #F5B400; outline-offset: 2px; }

.skip {
  position: absolute; left: -9999px; top: 0;
  background: #fff; color: var(--navy); padding: 8px 12px; z-index: 100;
}
.skip:focus { left: 8px; top: 8px; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px var(--pad);
  background: var(--navy);
  border-bottom: 4px solid var(--red);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.logo { width: 42px; height: 42px; flex: none; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.brand-name { color: #fff; font-weight: 700; font-size: 1.05rem; letter-spacing: .02em; }
.brand-tag { color: #AFC0DE; font-size: .78rem; }

.menu-btn {
  flex: none;
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 12px;
  background: transparent; color: #fff;
  border: 1px solid rgba(255,255,255,.35); border-radius: 8px;
  font: inherit; font-size: .9rem; cursor: pointer;
}
.menu-icon, .menu-icon::before, .menu-icon::after {
  display: block; width: 18px; height: 2px; background: currentColor; border-radius: 2px;
  transition: transform .2s ease, opacity .2s ease;
}
.menu-icon { position: relative; }
.menu-icon::before, .menu-icon::after { content: ""; position: absolute; left: 0; }
.menu-icon::before { top: -6px; }
.menu-icon::after { top: 6px; }
.nav-open .menu-icon { background: transparent; }
.nav-open .menu-icon::before { transform: translateY(6px) rotate(45deg); }
.nav-open .menu-icon::after { transform: translateY(-6px) rotate(-45deg); }

/* ---------- navigation ---------- */
.site-nav {
  display: none;
  background: var(--navy);
  padding: 6px 0 12px;
}
.nav-open .site-nav { display: block; }
.nav-list, .subnav { list-style: none; margin: 0; padding: 0; }
.nav-item > a {
  display: block; padding: 12px var(--pad);
  color: #fff; text-decoration: none; font-weight: 600;
  border-left: 4px solid transparent;
}
.nav-item > a:hover { background: var(--navy-hover); color: #fff; }
.nav-item.is-active > a { background: var(--navy-hover); border-left-color: var(--red); }
.subnav a {
  display: block; padding: 9px var(--pad) 9px calc(var(--pad) + 18px);
  color: #C9D3E6; text-decoration: none; font-size: .92rem;
}
.subnav a:hover { color: #fff; }
.subnav a[aria-current="page"] { color: #fff; font-weight: 600; }

/* ---------- content ---------- */
.content {
  padding: 20px var(--pad) 40px;
  min-width: 0;
}
.content > * + * { margin-top: 18px; }
.block > * + * { margin-top: 14px; }
.block + .block { padding-top: 6px; }

h1, h2, h3 { color: var(--ink); line-height: 1.3; margin: 0; }
h1 { font-size: clamp(1.45rem, 5vw, 2rem); font-weight: 700; }
h2 { font-size: clamp(1.15rem, 3.6vw, 1.4rem); font-weight: 700; }
h3 { font-size: 1.08rem; font-weight: 700; }
p { margin: 0; }
.lead { font-size: 1.05rem; color: var(--muted); }
.note { font-size: .82rem; color: var(--muted); line-height: 1.55; }
.eyebrow { font-weight: 700; color: var(--red-ink); }
.strong { font-weight: 700; }

h1 .inline-logo, h2 .inline-logo, h3 .inline-logo { height: 1.6em; width: auto; vertical-align: middle; margin-right: 8px; }
.inline-logo { height: 32px; width: auto; vertical-align: middle; margin-right: 6px; }

.title-band {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px; border-radius: var(--radius);
  color: #fff;
}
.title-band .inline-logo { margin: 0; }
.tag {
  display: inline-block; padding: 4px 10px; border-radius: 6px;
  font-size: .85rem; font-weight: 600; color: #fff;
}

.flow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.flow > p.note { flex: 0 1 auto; }

.btn {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px;
  background: var(--red); color: #fff; border-radius: 8px;
  font-weight: 700; text-decoration: none;
}
.btn:hover { background: var(--red-ink); color: #fff; }
.chip {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px;
  background: var(--navy-hover); color: #fff; border-radius: 999px;
  font-size: .9rem; font-weight: 600; text-decoration: none;
}
.chip:hover { background: var(--navy); color: #fff; }
.chip.is-current, .flow .tag[style*="background:#e31e24"] { background: var(--red); }

/* hero + images */
.hero { margin: 0; }
.hero img { display: block; width: 100%; border-radius: var(--radius); }
.gallery {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
}
.gallery figure { margin: 0; }
.gallery img { display: block; width: 100%; border-radius: 8px; background: #fff; }

.media { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.media-fig { flex: 0 0 auto; }
.media-img { display: block; max-width: 140px; border-radius: var(--radius); }
.media-body { flex: 1 1 260px; min-width: 0; }
.media-body > * + * { margin-top: 12px; }
.media--small { align-items: center; }
.media--small .media-img { max-width: 56px; }

/* stat cards */
.stats {
  display: grid; gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; text-align: center;
}
.stat-label { font-size: .72rem; font-weight: 700; color: var(--muted); letter-spacing: .03em; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--ink); line-height: 1.2; margin: 2px 0; }
.stat-sub { font-size: .75rem; color: var(--muted); }

/* banners (page-specific coloured headers) */
.banner {
  background: var(--banner-bg, var(--navy)); color: #fff;
  border-radius: var(--radius); padding: 16px;
}
.banner > * + * { margin-top: 8px; }
.banner h1, .banner h2, .banner h3 { color: #fff; }
.banner .flow { gap: 8px 16px; }
.banner .title-band { padding: 0; background: transparent !important; }
.banner .note { color: inherit; opacity: .85; }

/* ---------- tables ---------- */
.table-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
table { border-collapse: collapse; width: auto; min-width: 100%; font-size: .88rem; }
th, td { padding: 8px 10px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
td { white-space: nowrap; }
td.wrap { white-space: normal; min-width: 14rem; max-width: 22rem; }
tr.group td { white-space: normal; }
th {
  background: var(--th-bg, var(--navy)); color: #fff;
  font-weight: 600; font-size: .8rem; white-space: nowrap;
  position: sticky; top: 0;
}
tbody tr:nth-child(even) { background: var(--zebra); }
tbody tr:last-child td { border-bottom: 0; }
td.num { text-align: center; white-space: nowrap; }
td.b { font-weight: 700; }
tr.hl td { font-weight: 700; }
tr.group td {
  background: #E8EDF6; color: var(--ink); font-weight: 700; font-size: .82rem;
}
.team { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.flag { width: 22px; height: auto; border: 1px solid rgba(0,0,0,.08); flex: none; }

/* ---------- footer ---------- */
.site-footer {
  background: var(--navy-deep); color: #C9D3E6;
  padding: 16px var(--pad); font-size: .8rem; text-align: center;
}

/* ---------- larger screens ---------- */
@media (min-width: 600px) {
  .stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .media-img { max-width: 200px; }
  .gallery { grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); }
}

@media (min-width: 900px) {
  :root { --pad: 24px; }
  .logo { width: 56px; height: 56px; }
  .brand-name { font-size: 1.35rem; }
  .brand-tag { font-size: .9rem; }
  .menu-btn { display: none; }
  .layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: calc(100vh - 80px); }
  .site-nav { display: block; padding-top: 16px; }
  .site-nav .nav-list { position: sticky; top: 96px; }
  .content { padding: 28px 32px 48px; max-width: 1180px; }
  .content > * + * { margin-top: 22px; }
  table { font-size: .92rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
th.num { text-align: center; }
.hero img { max-width: 860px; }
.media-fig { display: flex; flex-wrap: wrap; gap: 6px; }
.logos { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.logos img { display: block; height: auto; }
.banner .tag { display: block; padding: 0; background: none !important; font-weight: 400; font-size: .88rem; border-radius: 0; }
.banner .gallery { grid-template-columns: repeat(auto-fill, minmax(90px, 120px)); }
.banner.card { text-align: center; }
.banner.card .gallery, .banner.card .logos { justify-content: center; }
.banner.card { max-width: 520px; }
.banner.card .title-band { justify-content: center; }
.banner.card .gallery { display: flex; flex-wrap: wrap; justify-content: center; }
.banner.card .gallery figure { width: 120px; }
.banner.card .tag { font-size: .9rem; }
.note, .lead, td.wrap { overflow-wrap: anywhere; }

.site-footer .disclaimer {
  max-width: 860px; margin: 10px auto 0;
  font-size: .74rem; line-height: 1.65; color: #9FB0CF; text-align: left;
}
.site-footer .disclaimer a { color: #C9D3E6; }
@media (min-width: 900px) { .site-footer .disclaimer { text-align: center; } }

/* rank / position badges inside tables */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.9em; height: 1.9em; padding: 0 .45em;
  border-radius: 999px; font-weight: 700; font-size: .85rem; line-height: 1;
}

/* tournament logos in page banners: same height on every page */
.banner:not(.card) .logos img { height: 88px; width: auto; max-width: 100%; object-fit: contain; }
@media (min-width: 900px) { .banner:not(.card) .logos img { height: 104px; } }
