/* Matchday Manager — mobile-first */
:root {
  --bg: #0a111e;
  --bg2: #0f1828;
  --card: #141f34;
  --card2: #1a2740;
  --line: #24344f;
  --line2: #1c2a42;
  --text: #e9eef9;
  --muted: #8b9ab4;
  --accent: #2ee59d;
  --accent2: #16b877;
  --warn: #ffb547;
  --bad: #ff5d6c;
  --blue: #4da3ff;
  --gold: #f5c542;
  --G: #f5b942;
  --D: #4da3ff;
  --M: #2ee59d;
  --F: #ff6b81;
  --r: 14px;
  --shadow: 0 8px 26px rgba(0, 0, 0, 0.35);
  --nav-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: radial-gradient(900px 500px at 0% -10%, #14305655, transparent), radial-gradient(700px 400px at 110% 0%, #0f5e4344, transparent), var(--bg);
  color: var(--text);
  font: 15px/1.5 'Sarabun', 'Noto Sans Thai', system-ui, sans-serif;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
h1, h2, h3, h4, .k { font-family: 'Kanit', 'Sarabun', sans-serif; font-weight: 600; margin: 0; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
button, input, select { font: inherit; color: inherit; }
img { display: block; }
.boot { display: grid; place-items: center; min-height: 100dvh; color: var(--muted); }

/* ---------- ปุ่ม/ฟอร์ม ---------- */
.btn {
  border: 1px solid var(--line); background: var(--card2); border-radius: 11px; padding: 9px 14px; min-height: 40px;
  cursor: pointer; font-weight: 600; transition: background 0.15s, border-color 0.15s, transform 0.06s; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:hover { border-color: #38507a; background: #213152; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #03140c; border-color: transparent; }
.btn.danger { border-color: #5a2630; color: #ffb3bb; }
.btn.sm { padding: 5px 10px; min-height: 32px; font-size: 13px; border-radius: 9px; }
.btn.lg { padding: 13px 22px; font-size: 17px; min-height: 50px; }
.btn.block { width: 100%; }
.btn.on { border-color: var(--accent); color: var(--accent); background: #12301f; }
.input { background: var(--bg2); border: 1px solid var(--line); border-radius: 11px; padding: 9px 12px; min-height: 40px; outline: none; min-width: 0; }
.input:focus { border-color: var(--accent); }
select.input { padding-right: 28px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.sm { font-size: 13px; }
.xs { font-size: 12px; }
.right { text-align: right; }
.center { text-align: center; }
.good { color: var(--accent); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }
.num { font-variant-numeric: tabular-nums; }
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px; white-space: nowrap; cursor: pointer; }
.chip.on { border-color: var(--accent); color: var(--accent); background: #12301f; }
.chip b { font-family: 'Kanit'; font-weight: 600; }
.seg { display: flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: none; padding: 8px 6px; border-radius: 9px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13px; }
.seg button.on { background: var(--card2); color: var(--accent); }

/* ---------- โครงหลัก ---------- */
.topbar { position: sticky; top: 0; z-index: 30; background: rgba(10, 17, 30, 0.88); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1200px; margin: 0 auto; padding: 8px 16px; display: flex; gap: 10px; align-items: center; }
.club { display: flex; gap: 10px; align-items: center; min-width: 0; flex: 1; }
.club h1 { font-size: 17px; }
.stat-chips { display: flex; gap: 6px; flex: none; }
.stat-chips .chip { cursor: default; padding: 4px 10px; }
nav.tabs { display: none; }
.shell { max-width: 1200px; margin: 0 auto; padding: 12px 16px calc(var(--nav-h) + var(--safe-b) + 20px); }
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: rgba(12, 20, 35, 0.96); backdrop-filter: blur(12px); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr);
}
.bottomnav button { border: 0; background: none; color: var(--muted); display: grid; place-items: center; align-content: center; gap: 1px; font-size: 11px; cursor: pointer; font-family: 'Kanit'; }
.bottomnav button i { font-style: normal; font-size: 21px; line-height: 1.1; }
.bottomnav button.on { color: var(--accent); }
@media (min-width: 900px) {
  nav.tabs { display: flex; max-width: 1200px; margin: 0 auto; padding: 0 16px; gap: 2px; overflow-x: auto; }
  .tab { background: none; border: none; padding: 10px 14px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; font-family: 'Kanit'; font-weight: 500; white-space: nowrap; }
  .tab:hover { color: var(--text); }
  .tab.on { color: var(--accent); border-bottom-color: var(--accent); }
  .bottomnav { display: none; }
  .shell { padding-bottom: 40px; padding-top: 18px; }
}
@media (max-width: 520px) {
  .stat-chips .hide-sm { display: none; }
  .club h1 { font-size: 15px; }
}

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: 1fr; }
@media (min-width: 900px) { .g2 { grid-template-columns: 1.35fr 1fr; } .g2e { grid-template-columns: 1fr 1fr; } }
.card { background: linear-gradient(180deg, var(--card), #111b2e); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); min-width: 0; }
.card + .card { margin-top: 0; }
.card-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.stack { display: grid; gap: 14px; align-content: start; }
.sec-title { font-family: 'Kanit'; font-size: 13px; color: var(--muted); margin: 14px 0 8px; text-transform: none; letter-spacing: 0.3px; }

/* ---------- ป้าย ---------- */
.logo { width: 34px; height: 34px; object-fit: contain; flex: none; }
.logo.lg { width: 64px; height: 64px; }
.logo.sm { width: 22px; height: 22px; }
.logo-fb { display: grid; place-items: center; border-radius: 50%; background: linear-gradient(135deg, #26406b, #1a6a50); font-family: 'Kanit'; font-weight: 600; color: #fff; font-size: 11px; }
.logo.lg.logo-fb { font-size: 22px; }
.logo.sm.logo-fb { font-size: 8px; }
.pos { display: inline-grid; place-items: center; min-width: 36px; font-size: 11px; font-weight: 700; padding: 2px 5px; border-radius: 6px; color: #07101d; font-family: 'Kanit'; line-height: 1.3; }
.pos.G { background: var(--G); } .pos.D { background: var(--D); } .pos.M { background: var(--M); } .pos.F { background: var(--F); }
.ovr { display: inline-grid; place-items: center; min-width: 34px; height: 28px; border-radius: 8px; font-family: 'Kanit'; font-weight: 700; background: #22324f; font-size: 15px; }
.ovr.t1 { background: linear-gradient(135deg, #c9a227, #8a6d12); color: #fff8dc; } .ovr.t2 { background: #1e7c55; } .ovr.t3 { background: #2f6044; } .ovr.t4 { background: #5d4a26; } .ovr.t5 { background: #5d3434; }
.form-dots { display: inline-flex; gap: 3px; vertical-align: middle; }
.form-dots i { width: 17px; height: 17px; border-radius: 5px; font-style: normal; font-size: 10px; font-weight: 700; display: grid; place-items: center; color: #07101d; }
.form-dots .W { background: var(--accent); } .form-dots .D { background: #b8c2d6; } .form-dots .L { background: var(--bad); }
.bar { height: 6px; background: #22314d; border-radius: 99px; overflow: hidden; min-width: 40px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bar.warn > i { background: var(--warn); } .bar.bad > i { background: var(--bad); }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 99px; background: #2a3958; white-space: nowrap; line-height: 1.6; }
.tag.inj { background: #5a2630; color: #ffc1c8; } .tag.sus { background: #5a4622; color: #ffe0a8; }
.tag.xi { background: #164a37; color: #9ff5cf; } .tag.sub { background: #1f3555; color: #b5d6ff; }
.tag.real { background: #173a52; color: #a8dcff; } .tag.est { background: #3a3350; color: #d2c6ff; }
.trait { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 3px 9px; border-radius: 99px; background: #183a2c; color: #b6f7d8; border: 1px solid #1f5a41; }
.trait.neg { background: #3d1c24; color: #ffc1c8; border-color: #6a2a37; }
.stars { color: var(--gold); letter-spacing: 1px; }
.stars .off { color: #3a4866; }

/* ---------- รายการนักเตะ ---------- */
.plist { display: grid; gap: 6px; }
.prow {
  display: grid; grid-template-columns: 38px 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 12px;
  background: var(--bg2); border: 1px solid var(--line2); cursor: pointer; min-height: 52px;
}
.prow:hover { border-color: var(--line); }
.prow.dim { opacity: 0.5; }
.prow.sel { border-color: var(--accent); background: #10291d; }
.prow .nm { font-weight: 600; }
.prow .sub { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.prow .rt { display: flex; gap: 8px; align-items: center; }
.prow .cond { width: 56px; display: grid; gap: 3px; }
.prow .extra { display: none; }
@media (min-width: 700px) {
  .prow.wide { grid-template-columns: 38px 1fr 90px 90px 60px 60px auto; }
  .prow.wide .extra { display: block; font-size: 13px; text-align: right; }
}
.list-head { display: none; }
@media (min-width: 700px) {
  .list-head.wide { display: grid; grid-template-columns: 38px 1fr 90px 90px 60px 60px auto; gap: 10px; padding: 0 10px 4px; font-size: 12px; color: var(--muted); }
}

/* ---------- ตาราง ---------- */
.tbl-wrap { overflow-x: auto; margin: 0 -4px; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 6px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 8px 6px; border-bottom: 1px solid var(--line2); white-space: nowrap; }
.tbl tr.me td { background: #123828; }
.tbl .team { display: flex; gap: 8px; align-items: center; max-width: 52vw; }
.tbl .team span { overflow: hidden; text-overflow: ellipsis; }
.tbl .r { text-align: right; }
.tbl .hide-m { display: none; }
@media (min-width: 640px) { .tbl .hide-m { display: table-cell; } }
.zt { box-shadow: inset 3px 0 0 var(--accent); } .zb { box-shadow: inset 3px 0 0 var(--bad); }

/* ---------- เริ่มเกม ---------- */
.setup { max-width: 1100px; margin: 0 auto; padding: 24px 16px 40px; }
.hero { text-align: center; margin: 10px 0 22px; }
.hero h1 { font-size: clamp(28px, 7vw, 42px); }
.hero h1 span { color: var(--accent); }
.hero p { color: var(--muted); margin: 6px 0 0; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 10px; }
.pick { display: flex; gap: 12px; align-items: center; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 11px; cursor: pointer; min-height: 60px; }
.pick:hover { border-color: #3a5a86; }
.pick.sel { border-color: var(--accent); background: #10301f; }
.pick .t { min-width: 0; flex: 1; }
.pick .t b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress { height: 10px; background: #1d2a43; border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent2), var(--accent)); transition: width 0.2s; }
.sticky-cta { position: sticky; bottom: 0; padding: 12px 0 calc(12px + var(--safe-b)); background: linear-gradient(transparent, var(--bg) 30%); z-index: 5; }

/* ---------- หน้าแรก ---------- */
.mc { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; text-align: center; padding: 6px 0; }
.mc .side { display: grid; justify-items: center; gap: 4px; min-width: 0; }
.mc .side b { font-family: 'Kanit'; font-size: 16px; max-width: 100%; }
.vs { font-family: 'Kanit'; font-size: 22px; color: var(--muted); }
.cmp { display: grid; grid-template-columns: 44px 1fr 44px; gap: 8px; align-items: center; font-size: 13px; margin-top: 8px; }
.bar2 { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: #22314d; }
.bar2 i:first-child { background: var(--accent); } .bar2 i:last-child { background: var(--blue); }
.news-item { padding: 10px 0; border-bottom: 1px solid var(--line2); }
.news-item:last-child { border-bottom: 0; }
.news-item .ttl { font-weight: 600; }
.news-item .body { color: var(--muted); font-size: 13px; white-space: pre-line; }
.news-item.win .ttl { color: var(--accent); } .news-item.loss .ttl { color: #ff97a1; } .news-item.injury .ttl::before { content: '🚑 '; } .news-item.transfer .ttl::before { content: '💼 '; }
.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kv > div { background: var(--bg2); border-radius: 10px; padding: 8px 10px; min-width: 0; }
.kv small { display: block; color: var(--muted); font-size: 11px; }
.kv b { font-family: 'Kanit'; font-size: 17px; }
.kv.k2 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 640px) { .kv.k4 { grid-template-columns: repeat(4, 1fr); } }

/* ---------- แผนการเล่น ---------- */
.pitch { position: relative; aspect-ratio: 68 / 96; border-radius: 16px; overflow: hidden; background: repeating-linear-gradient(180deg, #1b7a46 0 10%, #19703f 10% 20%); border: 2px solid #2d8f58; max-width: 520px; margin: 0 auto; width: 100%; }
.pitch::before { content: ''; position: absolute; left: 50%; top: 50%; width: 26%; aspect-ratio: 1; border: 2px solid #ffffff4d; border-radius: 50%; transform: translate(-50%, -50%); }
.pitch::after { content: ''; position: absolute; left: 0; right: 0; top: 50%; border-top: 2px solid #ffffff4d; }
.pitch .box { position: absolute; left: 22%; right: 22%; height: 14%; border: 2px solid #ffffff4d; }
.pitch .box.top { top: -2px; border-top: 0; } .pitch .box.bot { bottom: -2px; border-bottom: 0; }
.slot { position: absolute; transform: translate(-50%, -50%); width: 21%; display: grid; justify-items: center; gap: 1px; cursor: pointer; z-index: 2; text-align: center; }
.slot .shirt { width: clamp(30px, 9vw, 40px); height: clamp(30px, 9vw, 40px); border-radius: 50%; display: grid; place-items: center; font-family: 'Kanit'; font-weight: 700; color: #07101d; border: 2px solid #ffffffd0; box-shadow: 0 3px 8px #0007; font-size: clamp(12px, 3.4vw, 15px); position: relative; }
.slot.G .shirt { background: var(--G); } .slot.D .shirt { background: var(--D); } .slot.M .shirt { background: var(--M); } .slot.F .shirt { background: var(--F); }
.slot .nm { font-size: clamp(9px, 2.6vw, 11px); line-height: 1.2; background: #0a111ed9; padding: 1px 5px; border-radius: 5px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot .lb { font-size: 9px; color: #d9ffe9; font-family: 'Kanit'; }
.slot .lb.bad { color: #ffd38a; }
.slot.empty .shirt { background: #ffffff22; border-style: dashed; color: #fff; }
.slot.sel .shirt { outline: 3px solid #fff; outline-offset: 2px; }
.slot .badge { position: absolute; top: -5px; right: -7px; background: var(--gold); color: #000; font-size: 9px; border-radius: 99px; padding: 0 4px; font-weight: 700; }
.tactics-grid { display: grid; gap: 14px; }
@media (min-width: 900px) { .tactics-grid { grid-template-columns: minmax(320px, 460px) 1fr; } }
.field { display: grid; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); }
.fields { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }

/* ---------- โปรไฟล์นักเตะ ---------- */
.pcard { display: grid; grid-template-columns: 96px 1fr; gap: 14px; align-items: center; }
.pcard .photo { width: 96px; height: 96px; border-radius: 16px; object-fit: cover; background: #22314d; }
.pcard .big-ovr { font-family: 'Kanit'; font-size: 40px; font-weight: 700; line-height: 1; }
.face { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-top: 12px; }
.face div { background: var(--bg2); border-radius: 10px; padding: 6px 2px; text-align: center; }
.face b { display: block; font-family: 'Kanit'; font-size: 18px; }
.face small { font-size: 10px; color: var(--muted); }
.attrs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 12px; }
.attr-group h4 { font-size: 13px; color: var(--muted); margin-bottom: 4px; display: flex; justify-content: space-between; }
.attr { display: grid; grid-template-columns: 1fr 30px; gap: 6px; padding: 3px 0; border-bottom: 1px dashed #1f2d47; font-size: 13px; }
.attr b { text-align: right; font-family: 'Kanit'; }
.v1 { color: #33f0a6; } .v2 { color: #a6e36b; } .v3 { color: #f1d264; } .v4 { color: #ff9f5a; } .v5 { color: #ff6b6b; }
.posmap { position: relative; aspect-ratio: 68 / 80; background: #17663b; border-radius: 12px; border: 2px solid #2d8f58; max-width: 260px; margin: 0 auto; }
.posmap span { position: absolute; transform: translate(-50%, -50%); font-family: 'Kanit'; font-size: 11px; padding: 2px 5px; border-radius: 6px; background: #0a111ecc; text-align: center; line-height: 1.1; }
.posmap span.p0 { background: var(--accent); color: #04140c; } .posmap span.p1 { background: #9fe8c4; color: #04140c; } .posmap span.p2 { background: #e7d27a; color: #2a2200; }

/* ---------- หน้าแข่ง ---------- */
.match { max-width: 1100px; margin: 0 auto; padding: 0 0 calc(var(--safe-b) + 20px); }
.scoreboard { position: sticky; top: 0; z-index: 20; display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; background: linear-gradient(135deg, #0f203b, #0d2c23); border-bottom: 1px solid var(--line); padding: 10px 12px; }
.scoreboard .tm { display: flex; align-items: center; gap: 8px; min-width: 0; }
.scoreboard .tm.away { flex-direction: row-reverse; text-align: right; }
.scoreboard .tm b { font-family: 'Kanit'; font-size: clamp(13px, 3.6vw, 18px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score { text-align: center; }
.score .s { font-family: 'Kanit'; font-size: clamp(30px, 9vw, 44px); font-weight: 700; letter-spacing: 3px; line-height: 1; }
.score .clock { display: inline-block; margin-top: 4px; background: #0a111e; border: 1px solid var(--line); border-radius: 99px; padding: 1px 10px; font-family: 'Kanit'; color: var(--accent); font-size: 13px; }
.scorers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; font-size: 11px; color: var(--muted); padding: 4px 12px 0; }
.scorers div:last-child { text-align: right; }
.mbody { padding: 10px 12px; }
.controls { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 4px 0 10px; }
.mgrid { display: grid; gap: 12px; }
@media (min-width: 900px) { .mgrid { grid-template-columns: 1.3fr 1fr; } .mtabs { display: none !important; } .mpanel { display: block !important; } }
.mpanel { display: none; }
.mpanel.on { display: block; }
.feed { max-height: 62vh; overflow-y: auto; display: grid; gap: 3px; align-content: start; }
@media (min-width: 900px) { .feed { max-height: 560px; } }
.ev { display: grid; grid-template-columns: 44px 1fr; gap: 8px; padding: 6px 8px; border-radius: 8px; font-size: 14px; }
.ev .m { color: var(--muted); font-family: 'Kanit'; text-align: right; font-size: 13px; }
.ev.minor { opacity: 0.7; font-size: 13px; }
.ev.goal { background: #12402f; font-weight: 600; }
.ev.goal.them { background: #401a22; }
.ev.red { background: #3a1820; } .ev.injury { background: #34261a; }
.ev.yellow .t { color: #ffe08a; }
.ev.half, .ev.full { background: #1b2842; font-weight: 600; }
.stat { display: grid; grid-template-columns: 40px 1fr 40px; gap: 8px; align-items: center; font-size: 13px; margin: 9px 0; }
.stat .lbl { grid-column: 1 / -1; text-align: center; color: var(--muted); font-size: 12px; margin-bottom: -6px; }
.stat .b { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: #22314d; }
.stat .b i:first-child { background: var(--accent); } .stat .b i:last-child { background: var(--blue); margin-left: auto; }

/* ---------- modal / sheet ---------- */
.modal { position: fixed; inset: 0; background: #040913c4; display: flex; align-items: flex-end; justify-content: center; z-index: 60; }
.modal[hidden] { display: none; }
.modal .box {
  background: var(--card); border: 1px solid var(--line); border-radius: 20px 20px 0 0; padding: 16px 16px calc(16px + var(--safe-b));
  width: 100%; max-height: 92dvh; overflow-y: auto; box-shadow: var(--shadow); animation: up 0.18s ease-out;
}
.modal .grab { width: 40px; height: 4px; border-radius: 99px; background: #3a4a68; margin: -6px auto 10px; }
@keyframes up { from { transform: translateY(30px); opacity: 0.6; } }
@media (min-width: 760px) {
  .modal { align-items: center; padding: 20px; }
  .modal .box { border-radius: 20px; width: min(720px, 100%); max-height: 88vh; padding-bottom: 16px; }
  .modal .grab { display: none; }
}
.sheet-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; position: sticky; top: -16px; background: var(--card); padding: 6px 0; z-index: 2; }
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 14px); transform: translateX(-50%); background: #0f2b20; border: 1px solid var(--accent2); color: #cfffe8; padding: 10px 16px; border-radius: 12px; z-index: 70; box-shadow: var(--shadow); max-width: calc(100% - 32px); width: max-content; font-size: 14px; }
.toast.err { background: #3a1820; border-color: var(--bad); color: #ffd0d5; }
.toast[hidden] { display: none; }
@media (min-width: 900px) { .toast { bottom: 24px; } }
.empty { padding: 22px; text-align: center; color: var(--muted); }
.spinner { width: 18px; height: 18px; border: 2px solid #ffffff33; border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.note { background: #12283f; border: 1px solid #1f4a72; color: #cfe6ff; border-radius: 11px; padding: 9px 12px; font-size: 13px; }

/* ---------- safe-area (ขอบจอมือถือ/รอยบาก) ---------- */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 45; background: var(--bg); }
.topbar, .scoreboard { top: env(safe-area-inset-top, 0px); }
.topbar-in, .shell, .setup, .mbody, nav.tabs {
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.scoreboard { padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px)); }
.bottomnav { padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- ลิงก์ทีม / สถานะ / พัฒนาการ ---------- */
.tlink { cursor: pointer; border-radius: 8px; }
.tlink:hover .ell, .tlink:hover b { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
span.team { display: inline-flex; gap: 8px; align-items: center; min-width: 0; max-width: 100%; }
.tag.warnt { background: #4a3a1c; color: #ffd98f; }
.tag.hot { background: #4a2a12; color: #ffc08a; }
.tag.cold { background: #1d2f4d; color: #b8d4ff; }
.delta { font-family: 'Kanit'; font-size: 11px; font-weight: 600; }
.delta.up { color: var(--accent); } .delta.down { color: var(--bad); }
.attr .dl { font-size: 10px; margin-left: 4px; font-weight: 600; }

/* ---------- สรุปผลจบเกม ---------- */
.ft { text-align: center; position: relative; overflow: hidden; }
.ft::before { content: ""; position: absolute; inset: -40% -10% auto; height: 120%; background: radial-gradient(closest-side, var(--ftglow, #2ee59d33), transparent); pointer-events: none; }
.ft.loss { --ftglow: #ff5d6c2e; } .ft.draw { --ftglow: #8b9ab42e; }
.ft-eyebrow { font-family: 'Kanit'; letter-spacing: 3px; font-size: 12px; color: var(--muted); }
.ft-score { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin: 8px 0 4px; }
.ft-score .s { font-family: 'Kanit'; font-weight: 700; font-size: clamp(40px, 12vw, 64px); letter-spacing: 4px; animation: pop 0.5s cubic-bezier(.2,1.6,.4,1) both; }
.ft-score .tm { display: grid; justify-items: center; gap: 4px; min-width: 0; }
.ft-score .tm b { font-family: 'Kanit'; font-size: 14px; max-width: 100%; }
.ft-res { display: inline-block; font-family: 'Kanit'; font-weight: 600; padding: 3px 14px; border-radius: 99px; background: #164a37; color: #9ff5cf; animation: pop 0.5s 0.25s both; }
.ft.loss .ft-res { background: #4a1f28; color: #ffc1c8; } .ft.draw .ft-res { background: #2a3958; color: #d7e2f7; }
.ft-goals { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; text-align: left; font-size: 13px; margin-top: 12px; }
.ft-goals > div:nth-child(2) { text-align: right; }
.ft-goals .g { padding: 2px 0; animation: fadein 0.4s both; }
.motm { display: flex; gap: 12px; align-items: center; text-align: left; background: var(--bg2); border: 1px solid #5a4a16; border-radius: 14px; padding: 10px; margin-top: 12px; cursor: pointer; }
.motm .photo { width: 54px; height: 54px; border-radius: 12px; object-fit: cover; background: #22314d; flex: none; }
.motm .star { color: var(--gold); font-family: 'Kanit'; font-size: 12px; letter-spacing: 1px; }
.replay-bar { height: 6px; border-radius: 99px; background: #22314d; overflow: hidden; margin: 10px 0 4px; }
.replay-bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent2), var(--accent)); }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } }
.team-head { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; }
.sumchips { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- โซนขึ้น/ตกชั้น ---------- */
.zc { box-shadow: inset 3px 0 0 var(--blue); }
.zdot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.zdot.zt { background: var(--accent); box-shadow: none; } .zdot.zb { background: var(--bad); box-shadow: none; } .zdot.zc { background: var(--blue); box-shadow: none; }

/* ---------- วิเคราะห์เกม ---------- */
.mombar { position: relative; height: 22px; border-radius: 99px; background: linear-gradient(90deg, #2a1620, #1a2740); overflow: hidden; margin: 4px 0 12px; border: 1px solid var(--line); }
.mombar > i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, var(--accent2), var(--accent)); opacity: 0.55; transition: width 0.4s; }
.mombar > span { position: relative; display: block; text-align: center; font-size: 12px; line-height: 20px; font-family: 'Kanit'; }
.lanes { display: grid; grid-template-columns: 1.3fr repeat(3, 1fr); gap: 6px 8px; align-items: center; font-size: 13px; }
.lanes b { font-family: 'Kanit'; font-weight: 500; color: var(--muted); text-align: center; font-size: 12px; }
.lanes span { text-align: center; font-variant-numeric: tabular-nums; }
.lanes span:nth-child(4n + 1) { text-align: left; color: var(--muted); font-size: 12px; }
.hints { display: grid; gap: 8px; margin-top: 10px; font-size: 13px; }
.hints div { background: #12283f; border: 1px solid #1f4a72; color: #d6eaff; border-radius: 10px; padding: 8px 10px; }
.ht { border-color: var(--gold); background: linear-gradient(180deg, #2a2410, #141f34); }

/* ฟุตบอลถ้วย */
.win-t { font-weight: 700; }
.lose-t { opacity: .55; }
.cup-h { white-space: nowrap; }
.pick-grid.cups .pick { align-items: flex-start; text-align: left; }
.pick-grid.cups .t { display: grid; gap: 2px; min-width: 0; }

/* ช่องเซฟ */
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.slot-card { padding: 10px; border-radius: 12px; border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.03); min-width: 0; }
.slot-card.sel { border-color: #2ee59d; box-shadow: 0 0 0 1px #2ee59d inset; }

/* OVR แต่ละตำแหน่ง (FC Online) */
.posgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 6px; }
.posgrid > div { display: grid; justify-items: center; padding: 6px 4px; border-radius: 10px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08); }
.posgrid small { font-size: 10px; opacity: .7; }
.posgrid b { font-size: 16px; }
