:root {
  --blue-900: #0a2a66;
  --blue-800: #103b8c;
  --blue-700: #1650b8;
  --blue-500: #2a78e0;
  --green: #1f9d3f;
  --green-dark: #157a30;
  --gold: #f5c531;
  --red: #d22f43;
  --pink: #c0316b;
  --ink: #122036;
  --muted: #5b6b86;
  --line: #e3e9f2;
  --bg: #eef3fb;
  --card: #ffffff;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(16, 40, 90, 0.10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Kanit', 'Noto Sans Thai', system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
}

a { color: var(--blue-700); }
img { max-width: 100%; display: block; }

.container { width: min(1080px, 92vw); margin: 0 auto; }

/* ---------- Top bar ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(10, 42, 102, 0.96);
  backdrop-filter: blur(6px);
  color: #fff;
  box-shadow: 0 2px 14px rgba(0,0,0,.18);
}
.nav .container { display: flex; align-items: center; gap: 16px; padding: 12px 0; }
.nav .brand { font-weight: 700; font-size: 1.05rem; letter-spacing: .2px; }
.nav .brand small { display: block; font-weight: 300; font-size: .72rem; opacity: .8; }
.nav .links { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.nav .links a {
  color: #dce8ff; text-decoration: none; padding: 8px 14px; border-radius: 999px;
  font-size: .92rem; transition: .15s;
}
.nav .links a:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav .links a.cta { background: var(--green); color: #fff; font-weight: 600; }
.nav .links a.cta:hover { background: var(--green-dark); }

/* ---------- Hero ---------- */
.hero {
  background:
    radial-gradient(1200px 400px at 80% -10%, rgba(42,120,224,.55), transparent),
    linear-gradient(160deg, var(--blue-900), var(--blue-700) 70%, var(--green-dark));
  color: #fff;
  padding: 54px 0 70px;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 64px;
  background: repeating-linear-gradient(90deg, rgba(255,255,255,.05) 0 40px, rgba(255,255,255,.10) 40px 80px);
}
.hero .container { position: relative; z-index: 2; display: grid; grid-template-columns: 1.2fr .8fr; gap: 34px; align-items: center; }
.hero .badge {
  display: inline-block; background: var(--gold); color: #5a3b00; font-weight: 600;
  padding: 6px 16px; border-radius: 999px; font-size: .9rem; margin-bottom: 14px;
}
.hero h1 { font-size: 2.7rem; line-height: 1.15; margin: 0 0 6px; font-weight: 700; }
.hero h1 .y { color: var(--gold); }
.hero .sub { font-size: 1.15rem; opacity: .92; font-weight: 300; }
.hero .meta { margin: 22px 0 26px; display: grid; gap: 8px; }
.hero .meta div { display: flex; align-items: center; gap: 10px; font-size: 1.02rem; }
.hero .meta .ic { width: 26px; text-align: center; }
.hero .actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero .poster img { border-radius: 14px; box-shadow: 0 18px 50px rgba(0,0,0,.4); border: 4px solid rgba(255,255,255,.15); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  border: none; cursor: pointer; font-family: inherit; font-weight: 600;
  padding: 13px 26px; border-radius: 12px; font-size: 1rem; text-decoration: none;
  transition: transform .08s, box-shadow .15s, background .15s;
}
.btn:active { transform: translateY(1px); }
.btn-green { background: var(--green); color: #fff; box-shadow: 0 8px 20px rgba(31,157,63,.35); }
.btn-green:hover { background: var(--green-dark); }
.btn-gold { background: var(--gold); color: #5a3b00; }
.btn-gold:hover { filter: brightness(.96); }
.btn-ghost { background: rgba(255,255,255,.14); color: #fff; }
.btn-ghost:hover { background: rgba(255,255,255,.24); }
.btn-blue { background: var(--blue-700); color: #fff; }
.btn-blue:hover { background: var(--blue-800); }
.btn-outline { background: #fff; color: var(--blue-700); border: 1.5px solid var(--line); }
.btn-danger { background: #fff; color: var(--red); border: 1.5px solid #f3c2c9; }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-lg { padding: 15px 32px; font-size: 1.08rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ---------- Sections ---------- */
section { padding: 48px 0; }
.section-title { text-align: center; margin: 0 0 8px; font-size: 1.8rem; }
.section-lead { text-align: center; color: var(--muted); margin: 0 auto 34px; max-width: 640px; }

/* ---------- Division cards ---------- */
.divisions { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.div-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; border: 1px solid var(--line); display: flex; flex-direction: column;
}
.div-card .head { padding: 20px 24px; color: #fff; }
.div-card.youth .head { background: linear-gradient(135deg, var(--blue-800), var(--blue-500)); }
.div-card.public .head { background: linear-gradient(135deg, var(--pink), #e0467f); }
.div-card .head h3 { margin: 0; font-size: 1.3rem; }
.div-card .head .note { font-size: .85rem; opacity: .85; }
.div-card .body { padding: 18px 24px 24px; }
.prize-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.prize-row:last-child { border-bottom: none; }
.prize-row .medal { font-size: 1.2rem; }
.prize-row .place { flex: 1; font-weight: 500; }
.prize-row .money { font-weight: 700; color: var(--green-dark); }
.div-card .fee {
  margin-top: 16px; background: var(--bg); border-radius: 12px; padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between;
}
.div-card .fee b { font-size: 1.5rem; color: var(--blue-800); }

/* ---------- Info grid ---------- */
.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.info-card {
  background: var(--card); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
  border: 1px solid var(--line); text-align: center;
}
.info-card .ic { font-size: 2rem; }
.info-card h4 { margin: 8px 0 4px; }
.info-card p { margin: 0; color: var(--muted); }

/* ---------- ทีมที่สมัครแล้ว (หน้าแรก) ---------- */
#teamsWrap { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.team-group { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.team-group .tg-head { padding: 14px 18px; color: #fff; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.team-group.youth .tg-head { background: linear-gradient(135deg, var(--blue-800), var(--blue-500)); }
.team-group.public .tg-head { background: linear-gradient(135deg, var(--pink), #e0467f); }
.tg-count { background: rgba(255,255,255,.25); padding: 2px 12px; border-radius: 999px; font-size: .9rem; }
.team-list { margin: 0; padding: 8px 18px 16px; list-style: none; }
.team-list li { padding: 9px 0; border-bottom: 1px dashed var(--line); display: flex; align-items: center; gap: 10px; }
.team-list li:last-child { border-bottom: none; }
.team-list .rank { width: 24px; height: 24px; flex: none; background: var(--bg); border-radius: 50%; display: grid; place-items: center; font-size: .8rem; font-weight: 700; color: var(--muted); }
.team-list .aff { color: var(--muted); font-size: .9rem; }
.team-list .empty { color: var(--muted); justify-content: center; }
@media (max-width: 860px) { #teamsWrap { grid-template-columns: 1fr; } }

/* ---------- Contacts ---------- */
.contacts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.contact-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 18px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow);
}
.contact-card .av {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, var(--blue-700), var(--green)); color: #fff;
  display: grid; place-items: center; font-weight: 700;
}
.contact-card .nm { font-weight: 500; }
.contact-card a.ph { margin-left: auto; font-weight: 700; color: var(--green-dark); text-decoration: none; white-space: nowrap; }

/* ---------- Forms / cards ---------- */
.page { padding: 38px 0 70px; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--line); padding: 28px;
}
.card + .card { margin-top: 20px; }
.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 500; margin-bottom: 6px; }
.field .hint { font-weight: 300; color: var(--muted); font-size: .85rem; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 10px;
  font-family: inherit; font-size: 1rem; background: #fbfcfe; color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--blue-500); background: #fff;
  box-shadow: 0 0 0 3px rgba(42,120,224,.12);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* division radio cards */
.radio-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.radio-card {
  border: 2px solid var(--line); border-radius: 14px; padding: 16px; cursor: pointer;
  position: relative; transition: .15s; background: #fbfcfe;
}
.radio-card:hover { border-color: var(--blue-500); }
.radio-card input { position: absolute; opacity: 0; }
.radio-card.sel { border-color: var(--blue-700); background: #eef4ff; box-shadow: 0 0 0 3px rgba(22,80,184,.12); }
.radio-card .t { font-weight: 600; }
.radio-card .f { color: var(--green-dark); font-weight: 700; margin-top: 4px; }

.player-row { display: flex; gap: 8px; margin-bottom: 8px; }
.player-row input { flex: 1; }
.player-row button { flex: none; }

.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: .95rem; }
.alert-error { background: #fdecef; color: #a01b2d; border: 1px solid #f6c4cd; }
.alert-info { background: #eaf4ff; color: #11539b; border: 1px solid #c6e0ff; }
.alert-ok { background: #e9f8ee; color: #11703a; border: 1px solid #bfe9cd; }

.page-head { text-align: center; margin-bottom: 26px; }
.page-head h1 { margin: 0 0 4px; }
.page-head p { margin: 0; color: var(--muted); }

/* ---------- Payment ---------- */
.pay-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.qr-box { text-align: center; }
.qr-box .qrimg { width: 280px; max-width: 80%; margin: 6px auto 10px; border-radius: 12px; border: 1px solid var(--line); }
.qr-box .amt { font-size: 2rem; font-weight: 700; color: var(--blue-800); }
.promptpay-logo {
  display: inline-block; background: #003d6e; color: #fff; font-weight: 700;
  padding: 4px 12px; border-radius: 6px; font-size: .85rem; letter-spacing: .5px;
}
.steps { counter-reset: s; margin: 0; padding: 0; list-style: none; }
.steps li { counter-increment: s; position: relative; padding: 6px 0 6px 38px; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 6px; width: 26px; height: 26px;
  background: var(--blue-700); color: #fff; border-radius: 50%; display: grid; place-items: center;
  font-size: .85rem; font-weight: 700;
}

.kv { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); }

.statuschip { display: inline-block; padding: 3px 12px; border-radius: 999px; font-size: .82rem; font-weight: 600; }
.s-pending { background: #fff3d6; color: #946200; }
.s-slip_uploaded { background: #e0ecff; color: #1450a8; }
.s-paid { background: #dcf6e3; color: #156e34; }
.s-rejected { background: #fbe0e4; color: #a01b2d; }

/* ---------- Admin ---------- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 22px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); }
.stat .n { font-size: 1.7rem; font-weight: 700; color: var(--blue-800); }
.stat .l { color: var(--muted); font-size: .9rem; }

/* สรุปยอดแยกตามรุ่น */
.div-panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.div-panel .dp-head { padding: 12px 18px; color: #fff; font-weight: 600; }
.div-panel.youth .dp-head { background: linear-gradient(135deg, var(--blue-800), var(--blue-500)); }
.div-panel.public .dp-head { background: linear-gradient(135deg, var(--pink), #e0467f); }
.div-panel .dp-stats { display: grid; grid-template-columns: repeat(4, 1fr); }
.div-panel .dp-stats > div { padding: 14px 8px; text-align: center; border-right: 1px solid var(--line); }
.div-panel .dp-stats > div:last-child { border-right: none; }
.div-panel .dp-stats b { display: block; font-size: 1.5rem; color: var(--blue-800); }
.div-panel .dp-stats span { color: var(--muted); font-size: .82rem; }

/* แถวหัวข้อแบ่งกลุ่มรุ่นในตาราง */
tr.group-row td { font-weight: 700; padding: 12px; font-size: .98rem; }
tr.group-row.youth td { background: #eaf1ff; color: var(--blue-800); border-left: 4px solid var(--blue-700); }
tr.group-row.public td { background: #fdeaf2; color: var(--pink); border-left: 4px solid var(--pink); }

@media (max-width: 560px) {
  .div-panel .dp-stats b { font-size: 1.25rem; }
  .div-panel .dp-stats span { font-size: .72rem; }
}
table.tbl { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
table.tbl th, table.tbl td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); font-size: .92rem; vertical-align: middle; }
table.tbl th { background: var(--blue-900); color: #fff; font-weight: 500; position: sticky; top: 0; }
table.tbl tr:hover td { background: #f6f9ff; }
.tbl .mono { font-family: ui-monospace, monospace; font-weight: 600; }
.slip-thumb { width: 42px; height: 42px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); cursor: pointer; }
.row-actions { display: flex; gap: 6px; }
.mini { padding: 6px 12px; font-size: .82rem; border-radius: 8px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }

/* ---------- Footer ---------- */
.footer { background: var(--blue-900); color: #cdd9f0; padding: 30px 0; text-align: center; font-size: .9rem; margin-top: 30px; }
.footer .container { display: grid; gap: 6px; }

/* LINE join box */
.line-box {
  background: #f0faf0; border: 1.5px solid #b9e6b9; border-radius: 14px;
  padding: 16px 18px; margin: 18px 0;
}
.line-box .line-top { display: flex; align-items: center; gap: 14px; text-align: left; }
.line-box .line-text { flex: 1; }
.line-box .line-ic {
  width: 46px; height: 46px; flex: none; border-radius: 12px; background: #06c755;
  color: #fff; display: grid; place-items: center; font-size: 1.5rem;
}
.btn-line { background: #06c755; color: #fff; white-space: nowrap; }
.btn-line:hover { background: #05a948; }
.line-qr { text-align: center; margin-top: 14px; padding-top: 14px; border-top: 1px dashed #b9e6b9; }
.line-qr img { width: 160px; height: 160px; border-radius: 10px; border: 1px solid #b9e6b9; background: #fff; padding: 6px; }
.line-qr-cap { color: var(--green-dark); font-size: .88rem; margin-top: 6px; }
@media (max-width: 560px) {
  .line-box .line-top { flex-direction: column; text-align: center; }
  .line-box .line-text { text-align: center; }
  .btn-line { width: 100%; }
}

/* modal */
.modal { position: fixed; inset: 0; background: rgba(8,18,40,.75); display: none; place-items: center; z-index: 100; padding: 20px; }
.modal.open { display: grid; }
.modal img { max-width: 90vw; max-height: 86vh; border-radius: 10px; }
.modal-card {
  background: var(--card); border-radius: var(--radius); padding: 24px;
  width: min(560px, 94vw); max-height: 90vh; overflow-y: auto; text-align: left;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.modal-card select, .modal-card textarea, .modal-card input {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px;
  font-family: inherit; font-size: 1rem; background: #fbfcfe; color: var(--ink);
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .hero .container { grid-template-columns: 1fr; }
  .hero .poster { order: -1; max-width: 320px; margin: 0 auto; }
  .hero h1 { font-size: 2.1rem; }
  .divisions, .pay-grid, .grid-2, .radio-cards, .contacts { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .nav .brand small { display: none; }
  .table-wrap { overflow-x: auto; }
}
