/* =========================================================
   ARMWRESTLING THAILAND — ธีมกลาง (ดำ-แดง, Kanit)
   ใช้ทุกหน้าธีมหลัก: header, footer, ปุ่ม, การ์ด, ตาราง, empty state, pagination
   ========================================================= */
:root {
    --bg: #0b0b0d;
    --bg-2: #101013;
    --panel: #141418;
    --panel-2: #1b1b21;
    --border: #262630;
    --border-soft: #1f1f27;
    --text: #f5f5f7;
    --muted: #a0a3ad;   /* 7.8:1 บน --bg */
    --muted-2: #7f838e; /* 5.0:1 บน --bg, 4.7:1 บน --panel */
    --red: #e81c38;
    --red-2: #ff3146;
    --red-deep: #b2122a;
    --red-glow: rgba(232, 28, 56, .35);
    --gold: #f2c14e;
    --silver: #c7ccd6;
    --bronze: #d08a4f;
    --green: #2ecc80;
    --radius: 14px;
    --shadow: 0 10px 30px rgba(0, 0, 0, .45);
    --glow: 0 0 0 1px var(--red-glow), 0 0 28px rgba(232, 28, 56, .14);
    --font: "Kanit", "Sarabun", Tahoma, system-ui, sans-serif;
    color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-weight: 300;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-weight: 700; line-height: 1.2; margin: 0; letter-spacing: -.01em; overflow-wrap: anywhere; }
td, .person, .rank-info, .meta { overflow-wrap: anywhere; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
:focus-visible { outline: 3px solid #ff8a98; outline-offset: 3px; border-radius: 6px; box-shadow: 0 0 0 6px rgba(11, 11, 13, .9); }
.btn:focus-visible, .page-link:focus-visible, .tabs a:focus-visible { outline-offset: 2px; }

.skip-link {
    position: absolute; left: 12px; top: -60px; z-index: 100;
    padding: 10px 16px; border-radius: 10px; background: var(--red-2); color: #fff; font-weight: 600;
    transition: top .15s;
}
.skip-link:focus { top: 12px; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- Header ---------- */
.site-header {
    position: sticky; top: 0; z-index: 50;
    background: rgba(11, 11, 13, .9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-soft);
}
.site-header::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
    background: linear-gradient(90deg, transparent, var(--red) 30%, var(--red) 70%, transparent);
    opacity: .55;
}
.header-inner { display: flex; align-items: center; gap: 18px; height: 70px; }
.brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.brand .emblem {
    width: 44px; height: 44px; display: grid; place-items: center; color: var(--red-2);
    border-radius: 12px; background: rgba(232, 28, 56, .1); box-shadow: inset 0 0 0 1px rgba(232, 28, 56, .35);
}
.brand .brand-text { line-height: 1; }
.brand .brand-text b { display: block; font-weight: 800; font-size: 19px; letter-spacing: .04em; }
.brand .brand-text span { display: block; font-size: 10px; letter-spacing: .5em; color: var(--muted); margin-top: 4px; }

.main-nav { display: flex; gap: 2px; margin-left: 14px; }
.main-nav a {
    position: relative; padding: 8px 15px; border-radius: 9px;
    color: var(--muted); font-weight: 500; font-size: 15px; transition: color .15s, background .15s;
}
.main-nav a:hover { color: var(--text); background: rgba(255, 255, 255, .04); }
.main-nav a.active { color: #fff; }
.main-nav a.active::after {
    content: ""; position: absolute; left: 15px; right: 15px; bottom: 2px; height: 2px; border-radius: 2px;
    background: var(--red-2); box-shadow: 0 0 10px var(--red-2);
}

.header-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.search-box {
    display: flex; align-items: center; gap: 8px;
    background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
    padding: 0 10px; height: 40px; width: 42px; overflow: hidden;
    transition: width .2s ease, border-color .15s;
}
.search-box:focus-within, .search-box.is-open { width: 230px; border-color: var(--red); }
.search-box button { display: grid; place-items: center; color: var(--muted); flex-shrink: 0; width: 20px; }
.search-box input { border: 0; background: none; outline: none; width: 100%; font-size: 14px; min-width: 0; }
.search-box input::placeholder { color: var(--muted-2); }

.avatar-chip {
    display: inline-flex; align-items: center; gap: 9px; padding: 4px 12px 4px 4px;
    border: 1px solid var(--border); border-radius: 999px; background: var(--panel); font-size: 14px; font-weight: 500;
}
.avatar-chip:hover { border-color: var(--red); }
.avatar {
    width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
    background: linear-gradient(135deg, var(--red-2), var(--red-deep)); color: #fff; font-weight: 700; font-size: 15px;
}
.avatar.lg { width: 56px; height: 56px; font-size: 22px; }
.avatar.xl { width: 96px; height: 96px; font-size: 38px; }
.avatar.gray { background: var(--panel-2); color: var(--muted); box-shadow: inset 0 0 0 1px var(--border); }

.nav-toggle { display: none; width: 40px; height: 40px; place-items: center; color: var(--text); border: 1px solid var(--border); border-radius: 10px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 18px; border-radius: 10px; font-weight: 600; font-size: 15px; white-space: nowrap;
    transition: transform .12s, box-shadow .15s, background .15s, border-color .15s;
}
.btn:active { transform: translateY(1px); }
.btn-red { background: linear-gradient(135deg, var(--red-2), var(--red-deep)); color: #fff; box-shadow: 0 6px 18px rgba(232, 28, 56, .35); }
.btn-red:hover { box-shadow: 0 8px 26px rgba(232, 28, 56, .55); }
.btn-ghost { border: 1px solid var(--red); color: #fff; background: rgba(232, 28, 56, .08); }
.btn-ghost:hover { background: rgba(232, 28, 56, .2); }
.btn-dark { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); }
.btn-dark:hover { border-color: var(--muted-2); }
.btn-sm { padding: 7px 13px; font-size: 13px; border-radius: 8px; }

/* ---------- Page head / sections ---------- */
.page-head { padding: 44px 0 26px; border-bottom: 1px solid var(--border-soft); background: radial-gradient(900px 300px at 15% 0%, rgba(232, 28, 56, .18), transparent 70%); }
.page-head .eyebrow { display: inline-flex; align-items: center; gap: 8px; color: var(--red-2); font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 8px; }
.page-head h1 { font-size: clamp(28px, 4vw, 42px); }
.page-head p { color: var(--muted); margin-top: 8px; max-width: 640px; }
.page-head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }

.section { padding: 44px 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.section-title { display: flex; align-items: center; gap: 12px; font-size: 22px; }
.section-title::before { content: ""; width: 5px; height: 26px; border-radius: 3px; background: linear-gradient(var(--red-2), var(--red-deep)); box-shadow: 0 0 12px var(--red-glow); }
.section-title.sm { font-size: 18px; }
.section-title.sm::before { height: 20px; }
.see-all { color: var(--muted); font-weight: 500; font-size: 14px; display: inline-flex; gap: 6px; align-items: center; }
.see-all:hover { color: var(--red-2); }

/* ---------- Cards ---------- */
.card { background: var(--panel); border: 1px solid var(--border-soft); border-radius: var(--radius); overflow: hidden; }
.card.glow { border-color: rgba(232, 28, 56, .45); box-shadow: var(--glow); }
.card-pad { padding: 18px; }
.card-link { transition: transform .15s, border-color .15s, box-shadow .15s; }
.card-link:hover { transform: translateY(-3px); border-color: rgba(232, 28, 56, .55); box-shadow: var(--glow); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 6px; font-size: 12px; font-weight: 600; background: linear-gradient(135deg, var(--red-2), var(--red-deep)); color: #fff; }
.badge-outline { background: rgba(232, 28, 56, .08); color: var(--red-2); border: 1px solid rgba(232, 28, 56, .4); }
.badge-gray { background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); }
.badge-green { background: rgba(46, 204, 128, .12); color: var(--green); border: 1px solid rgba(46, 204, 128, .4); }
.badge-verified { background: rgba(46, 204, 128, .12); color: var(--green); border: 1px solid rgba(46, 204, 128, .4); }

.meta { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: 14px; }
.meta span { display: inline-flex; align-items: center; gap: 6px; }
.meta svg { color: var(--red-2); }

/* ---------- Tabs / filters ---------- */
.tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; }
.tabs a, .tabs button { padding: 8px 18px; border-radius: 9px; color: var(--muted); font-weight: 500; font-size: 14px; }
.tabs a:hover { color: var(--text); }
.tabs a.is-on, .tabs button.is-on { background: linear-gradient(135deg, var(--red-2), var(--red-deep)); color: #fff; box-shadow: 0 4px 14px rgba(232, 28, 56, .35); }

.search-form { display: flex; gap: 10px; }
.search-form .field { flex: 1; display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 0 14px; height: 48px; }
.search-form .field:focus-within { border-color: var(--red); box-shadow: var(--glow); }
.search-form .field svg { color: var(--muted-2); flex-shrink: 0; }
.search-form input { flex: 1; border: 0; background: none; outline: none; font-size: 15px; min-width: 0; }
.search-form input::placeholder { color: var(--muted-2); }

select.select, .select {
    background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px; padding: 9px 12px; font-size: 14px; outline: none; color: var(--text);
}

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* มือถือ: ให้ตารางเลื่อนแนวนอนภายในกรอบ แทนการบีบชื่อนักกีฬาจนแตกทีละตัวอักษร */
.table-wrap > .table { min-width: 560px; }
.table .person b, .table .person small { white-space: nowrap; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; color: var(--muted-2); font-weight: 500; letter-spacing: .04em; padding: 11px 14px; border-bottom: 1px solid var(--border-soft); white-space: nowrap; }
.table td { padding: 13px 14px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: rgba(255, 255, 255, .02); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

.place {
    display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
    font-weight: 700; font-size: 15px; background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--border);
}
.place.p1 { background: linear-gradient(135deg, #ffe08a, var(--gold)); color: #1a1205; box-shadow: 0 0 14px rgba(242, 193, 78, .45); }
.place.p2 { background: linear-gradient(135deg, #eef1f6, var(--silver)); color: #1a1a1a; }
.place.p3 { background: linear-gradient(135deg, #f0b985, var(--bronze)); color: #1a1205; }

.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person b { display: block; font-weight: 600; font-size: 15px; line-height: 1.25; }
.person small { display: block; color: var(--muted); font-size: 12px; }
.person a:hover b { color: var(--red-2); }

/* ---------- Rank list (Top 3) ---------- */
.rank-list { display: flex; flex-direction: column; gap: 10px; }
.rank-row {
    display: flex; align-items: center; gap: 14px; padding: 12px 14px;
    background: var(--panel-2); border: 1px solid var(--border-soft); border-radius: 12px; transition: border-color .15s;
}
.rank-row:hover { border-color: rgba(232, 28, 56, .5); }
.rank-row .rank-info { min-width: 0; flex: 1; }
.rank-row .rank-info b { display: block; font-size: 16px; font-weight: 600; line-height: 1.3; }
.rank-row .rank-info span { color: var(--muted); font-size: 13px; }

/* ---------- Empty state ---------- */
.empty {
    text-align: center; padding: 42px 20px; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius);
    background: var(--bg-2);
}
.empty svg { color: var(--muted-2); margin-bottom: 10px; }
.empty b { display: block; color: var(--text); font-weight: 600; font-size: 16px; margin-bottom: 4px; }
.empty.compact { padding: 26px 16px; }

/* ---------- Pagination ---------- */
.pagination { display: flex; justify-content: center; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 28px; }
.page-link { padding: 8px 13px; border-radius: 9px; border: 1px solid var(--border); background: var(--panel); font-size: 14px; color: var(--muted); font-weight: 500; }
.page-link:hover { color: var(--text); border-color: var(--red); }
.page-link.is-current { background: linear-gradient(135deg, var(--red-2), var(--red-deep)); color: #fff; border-color: transparent; }
.page-link.is-disabled { opacity: .4; pointer-events: none; }
.page-gap { color: var(--muted-2); padding: 0 4px; }

/* ---------- Grids ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat { padding: 16px 18px; background: var(--panel); border: 1px solid var(--border-soft); border-radius: 12px; }
.stat b { display: block; font-size: 28px; font-weight: 700; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 13px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border-soft); margin-top: 40px; padding: 34px 0 28px; background: var(--bg-2); }
.footer-inner { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.footer-nav { display: flex; gap: 4px 18px; flex-wrap: wrap; }
.footer-nav a { color: var(--muted); font-size: 14px; font-weight: 500; }
.footer-nav a:hover { color: var(--text); }
.footer-social { display: flex; gap: 10px; margin-left: auto; }
.footer-social a { width: 36px; height: 36px; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--border); display: grid; place-items: center; color: var(--muted); transition: color .15s, border-color .15s; }
.footer-social a:hover { color: var(--red-2); border-color: var(--red); }
.footer-note { width: 100%; color: var(--muted-2); font-size: 13px; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
    .header-inner { height: 64px; }
    .nav-toggle { display: grid; }
    .main-nav {
        display: none; position: absolute; left: 0; right: 0; top: 64px; margin: 0; padding: 10px 16px 14px;
        flex-direction: column; background: rgba(11, 11, 13, .98); border-bottom: 1px solid var(--border);
    }
    body.nav-open .main-nav { display: flex; }
    .main-nav { max-height: calc(100dvh - 64px); overflow-y: auto; z-index: 60; }
    .main-nav a { padding: 12px 10px; font-size: 16px; border-radius: 8px; }
    .main-nav a.active::after { display: none; }
    .main-nav a.active { color: var(--red-2); }
    .nav-toggle .ic-close { display: none; }
    body.nav-open .nav-toggle { border-color: var(--red); color: var(--red-2); }
    body.nav-open .nav-toggle .ic-menu { display: none; }
    body.nav-open .nav-toggle .ic-close { display: block; }
    .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
    .stats { grid-template-columns: 1fr 1fr; }
    .avatar-chip span { display: none; }
    .avatar-chip { padding: 3px; }
}
@media (max-width: 620px) {
    .wrap { padding: 0 14px; }
    .section { padding: 30px 0; }
    .page-head { padding: 30px 0 20px; }
    .page-head-row { align-items: flex-start; }
    .tabs { width: 100%; }
    .tabs a { flex: 1; text-align: center; padding: 8px 10px; }
    .search-form { flex-wrap: wrap; }
    .search-form .field { flex-basis: 100%; }
    .stats { grid-template-columns: 1fr 1fr; }
    .table th, .table td { padding: 10px 8px; }
    .place { width: 30px; height: 30px; font-size: 13px; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .header-inner { gap: 10px; position: relative; }
    .brand { gap: 8px; }
    .brand .emblem { width: 36px; height: 36px; border-radius: 10px; }
    .brand .brand-text b { font-size: 15px; }
    .brand .brand-text span { display: none; }
    .header-tools { gap: 8px; }
    .header-tools .btn span { display: none; }
    .header-tools .btn { padding: 9px 11px; }
    /* ช่องค้นหาขยายเป็นชั้นทับแถบหัว ไม่ดันโลโก้ตกขอบ */
    .search-box:focus-within, .search-box.is-open {
        position: absolute; left: 0; right: 0; top: 12px; width: auto; z-index: 5;
        height: 40px; background: var(--panel-2);
    }
    .footer-social { margin-left: 0; }
}
@media (max-width: 400px) {
    .brand .brand-text { display: none; }
}
