/* SA GAMES — หน้าสาธารณะ (ไม่ต้อง Login) ใช้ token เดียวกับระบบ (app.css) */
body.pub { background: var(--paper); }
.pub-top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.pub-top-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; max-width: 1240px; margin: 0 auto; padding: .7rem clamp(1rem, 3vw, 2rem) .2rem; }
.pub-brand { font-family: var(--font-head); font-weight: 600; font-size: 1.3rem; color: var(--ink); text-decoration: none; display: flex; flex-direction: column; line-height: 1.15; }
.pub-brand span { font-family: var(--font-body); font-weight: 400; font-size: .8rem; color: var(--muted); }
.pub-login { font-size: .9rem; white-space: nowrap; }
.pub-nav { display: flex; gap: .25rem; max-width: 1240px; margin: 0 auto; padding: .35rem clamp(1rem, 3vw, 2rem) .5rem; overflow-x: auto; scrollbar-width: none; }
.pub-nav::-webkit-scrollbar { display: none; }
.pub-nav a { white-space: nowrap; padding: .35rem .85rem; border-radius: 999px; color: var(--ink); text-decoration: none; font-size: .95rem; display: inline-flex; align-items: center; gap: .4rem; }
.pub-nav a:hover { background: var(--paper); }
.pub-nav a.active { background: var(--ink); color: #FFFFFF; }
.pub-live-dot { width: .55rem; height: .55rem; border-radius: 50%; background: #E0242E; }
.pub-strip { margin: 0; height: 4px; border-radius: 0; }
.pub-main { max-width: 1240px; margin: 0 auto; padding: 1.5rem clamp(1rem, 3vw, 2rem) 2rem; }
.pub-foot { text-align: center; color: var(--muted); font-size: .85rem; padding: 1.5rem 1rem 2rem; }
.pub-live { display: inline-flex; align-items: center; gap: .35rem; background: #E0242E; color: #fff; border-radius: 999px; padding: .05rem .6rem; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.pub-day-list { display: grid; gap: .6rem; }
.pub-slot { display: grid; grid-template-columns: 4.2rem 1fr auto; gap: .75rem; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem; }
.pub-slot.is-live { border-color: #E0242E; box-shadow: inset 4px 0 0 #E0242E; }
.pub-slot.is-done { opacity: .7; }
.pub-slot time { font-family: var(--font-head); font-weight: 500; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.pub-slot h3 { font-size: 1rem; font-weight: 500; margin: 0; }
.pub-slot p { margin: 0; color: var(--muted); font-size: .85rem; }
.pub-podium { list-style: none; padding: 0; margin: 0; }
.pub-podium li { display: grid; grid-template-columns: 2.2rem 1fr auto; gap: .6rem; align-items: center; padding: .45rem 0; border-top: 1px solid var(--line); }
.pub-podium li:first-child { border-top: 0; }
.pub-place { width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-head); font-weight: 600; border: 2px solid var(--line); }
.pub-place.has-medal { background: var(--medal); border-color: var(--medal); color: #1B1B1B; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.pub-results-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.pub-ann { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1.1rem 1.25rem; }
.pub-ann + .pub-ann { margin-top: .75rem; }
.pub-ann h2 { font-size: 1.15rem; font-weight: 500; margin: 0 0 .25rem; }
.pub-ann-body { white-space: pre-line; max-width: 72ch; }
.pub-athlete { display: grid; grid-template-columns: 1fr auto; gap: .25rem .75rem; padding: .7rem 0; border-top: 1px solid var(--line); }
.pub-athlete:first-child { border-top: 0; }
.pub-athlete-events { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .3rem; }
.pub-chip { font-size: .8rem; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: .05rem .6rem; }
@media (min-width: 1800px) { .pub-main, .pub-top-inner, .pub-nav { max-width: 1600px; } html { font-size: 18px; } }
@media (max-width: 575px) { .pub-slot { grid-template-columns: 3.4rem 1fr; } .pub-slot > :last-child { grid-column: 2; } }
/* --- Phase 11 หน้าย่อย --- */
.pub-head { margin-bottom: 1.1rem; }
.pub-head h1 { font-size: clamp(1.5rem, 1.1rem + 1.4vw, 2.2rem); font-weight: 600; margin: 0 0 .2rem; display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.pub-head p { color: var(--muted); margin: 0; }
.pub-h2 { font-size: 1.2rem; font-weight: 500; margin: 1.5rem 0 .75rem; }
.pub-back { margin-bottom: .5rem; font-size: .9rem; }
.pub-back a { text-decoration: none; }
.pub-empty { text-align: center; padding: 4rem 1rem; }
.pub-empty-line { color: var(--muted); padding: 2rem 0; text-align: center; }
.pub-days { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .35rem; margin-bottom: 1rem; scrollbar-width: thin; }
.pub-days a { flex: none; display: flex; flex-direction: column; align-items: center; padding: .45rem .9rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); text-decoration: none; line-height: 1.2; }
.pub-days a small { font-size: .72rem; color: #E0242E; }
.pub-days a.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.pub-days a.active small { color: #FFB4B8; }
.pub-filter { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; max-width: 640px; }
.pub-filter > .form-control, .pub-filter > .form-select { flex: 1 1 12rem; }
.pub-filter-3 { max-width: 900px; }
.pub-day-list { list-style: none; padding: 0; margin: 0; }
.pub-slot h3 a { color: inherit; text-decoration: none; }
.pub-slot h3 a:hover { text-decoration: underline; }
.pub-state, .pub-state-done { font-size: .85rem; color: var(--muted); white-space: nowrap; }
.pub-state-done { color: #1E7B4F; font-weight: 500; }
.pub-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1rem 1.15rem; margin-bottom: 1rem; }
.pub-card > h2, .pub-card > h3 { font-size: 1.1rem; font-weight: 500; margin: 0 0 .6rem; }
.pub-results-grid > .pub-card { margin-bottom: 0; }
.pub-card-title a { color: inherit; text-decoration: none; }
.pub-card-title a:hover { text-decoration: underline; }
.pub-card-meta { color: var(--muted); font-size: .85rem; margin: -.35rem 0 .5rem; }
.pub-house { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; white-space: nowrap; }
.pub-house::before { content: ""; width: .7rem; height: .7rem; border-radius: 3px; background: var(--house); box-shadow: 0 0 0 1px rgba(0, 0, 0, .15); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.pub-mark { font-family: var(--font-head); font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pub-place-sm { width: .9rem; height: .9rem; display: inline-block; vertical-align: -.1rem; }
.pub-table th { font-weight: 500; color: var(--muted); font-size: .85rem; }
.pub-table tbody th { color: var(--ink); font-size: .95rem; font-weight: 400; }
.pub-table a { color: inherit; }
.pub-lanes { list-style: none; padding: 0; margin: 0; }
.pub-lanes li { display: grid; grid-template-columns: 2rem 1fr auto; gap: .6rem; align-items: center; padding: .4rem 0; border-top: 1px solid var(--line); }
.pub-lanes li:first-child { border-top: 0; }
.pub-lane-no { width: 1.8rem; height: 1.8rem; display: grid; place-items: center; border-radius: 6px; background: var(--house); color: #fff; font-family: var(--font-head); font-weight: 600; text-shadow: 0 1px 2px rgba(0, 0, 0, .45); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
/* Scoreboard หน้าคะแนน — ลู่วิ่งเหมือนหน้า Live */
.pub-board { list-style: none; padding: 0; margin: 0 0 1.25rem; display: grid; gap: .6rem; }
.pub-board li { display: grid; grid-template-columns: 2.6rem 1fr auto; gap: .9rem; align-items: center; background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--house); border-radius: var(--radius); padding: .7rem 1rem; }
.pub-board-rank { font-family: var(--font-head); font-size: 1.7rem; font-weight: 700; text-align: center; }
.pub-board-head { margin-bottom: .3rem; }
.pub-board-bar { height: .65rem; border-radius: 99px; background: var(--paper); overflow: hidden; }
.pub-board-bar span { display: block; height: 100%; background: var(--house); border-radius: 99px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.pub-board-score { font-family: var(--font-head); font-size: 1.7rem; font-weight: 600; text-align: right; line-height: 1; font-variant-numeric: tabular-nums; }
.pub-board-score small { display: block; font-family: var(--font-body); font-size: .72rem; font-weight: 400; color: var(--muted); }
.pub-matrix { max-height: 70vh; }
.pub-athletes { list-style: none; padding: 0; margin: 0; }
.pub-chip-medal { border-color: var(--medal); box-shadow: inset 3px 0 0 var(--medal); }
.pub-ann.is-pinned { border-color: var(--ink); }
.pub-ann h2 a { color: inherit; text-decoration: none; }
.pub-ann h2 a:hover { text-decoration: underline; }
.pub-ann-date { color: var(--muted); font-size: .85rem; margin: 0 0 .25rem; }
.pub-ann-full h1 { font-size: clamp(1.4rem, 1.1rem + 1vw, 2rem); font-weight: 600; }
.pub-table { --bs-table-bg: transparent; }
.pub-matrix tbody th { min-width: 10rem; }
.pub-table th, .pub-table td { white-space: nowrap; }
.pub-table td:nth-child(2) { white-space: normal; min-width: 10rem; }
/* --- Phase 12 ตรวจสอบเกียรติบัตร --- */
.cv { max-width: 640px; margin: 0 auto; }
.cv-seal { display: flex; gap: 1rem; align-items: center; border-radius: var(--radius-lg); padding: 1.25rem 1.4rem; margin-bottom: 1rem; border: 2px solid; }
.cv-seal.is-valid { background: #E8F6EE; border-color: #1E7B4F; color: #14532D; }
.cv-seal.is-revoked { background: #FDECEC; border-color: #B42318; color: #7A1A12; }
.cv-seal.is-unknown { background: var(--surface); border-color: var(--line); color: var(--ink); }
.cv-mark { flex: none; width: 3.2rem; height: 3.2rem; border-radius: 50%; display: grid; place-items: center; font-size: 1.7rem; font-weight: 700; color: #fff; background: currentColor; }
.cv-seal.is-valid .cv-mark { background: #1E7B4F; }
.cv-seal.is-revoked .cv-mark { background: #B42318; }
.cv-seal.is-unknown .cv-mark { background: var(--muted); }
.cv-state { font-family: var(--font-head); font-weight: 700; font-size: clamp(1.35rem, 1rem + 1.5vw, 1.9rem); letter-spacing: .02em; margin: 0; line-height: 1.15; }
.cv-state-th { margin: .2rem 0 0; }
.cv-facts { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: .4rem 1.2rem; margin: 0 0 1.25rem; }
.cv-facts > div { display: grid; grid-template-columns: 6.5rem 1fr; gap: .75rem; padding: .6rem 0; border-top: 1px solid var(--line); }
.cv-facts > div:first-child { border-top: 0; }
.cv-facts dt { color: var(--muted); font-weight: 400; }
.cv-facts dd { margin: 0; font-weight: 500; }
.cv-revoked dd { color: #B42318; }
.cv-form { display: flex; gap: .5rem; }

/* ---------- แบนเนอร์ (Phase 14) — รูปที่อัปโหลด หรือแบนเนอร์เริ่มต้นจากชื่องาน + สีคณะ ---------- */
.pub-banner { position: relative; overflow: hidden; background: #141B33; }
.pub-banner-img img { display: block; width: 100%; height: auto; max-height: 420px; object-fit: cover; }
.pub-banner-default { min-height: clamp(128px, 16vw, 230px); display: flex; align-items: center; color: #fff;
  background: radial-gradient(120% 140% at 0% 0%, #2B3A80 0%, #141B33 55%, #0D1226 100%); }
.pub-banner-text { position: relative; z-index: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: 1.1rem clamp(1rem, 3vw, 2rem); }
.pub-banner-kicker { margin: 0; font-size: clamp(.8rem, .7rem + .4vw, 1.05rem); letter-spacing: .02em; opacity: .85; }
.pub-banner-title { margin: .1rem 0 .15rem; font-family: var(--font-head); font-weight: 700; line-height: 1.05;
  font-size: clamp(2rem, 1.2rem + 4vw, 4.4rem); text-shadow: 0 2px 18px rgba(0, 0, 0, .35); }
.pub-banner-date { margin: 0; display: inline-block; font-family: var(--font-head); font-weight: 500; font-size: clamp(.85rem, .75rem + .5vw, 1.15rem);
  padding: .15rem .7rem; border-radius: 999px; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .25); }
/* ลู่วิ่งตามสีคณะ: แถบเอียงฝั่งขวา วิ่งเข้าเมื่อเปิดหน้า */
.pub-banner-lanes { position: absolute; inset: -20% -6% -20% 46%; display: flex; flex-direction: column; justify-content: center; gap: 9px; transform: skewX(-18deg); }
.pub-banner-lanes span { display: block; flex: 1; max-height: 34px; background: var(--lane);
  border-top: 2px solid rgba(255, 255, 255, .55); border-bottom: 2px solid rgba(255, 255, 255, .55); opacity: .92;
  transform: translateX(110%); animation: pub-lane-in .9s cubic-bezier(.2, .8, .2, 1) forwards; animation-delay: calc(var(--i) * 110ms); }
@keyframes pub-lane-in { to { transform: translateX(0); } }
@media (prefers-reduced-motion: reduce) { .pub-banner-lanes span { animation: none; transform: none; } }
@media (max-width: 640px) {
  .pub-banner-lanes { inset: -20% -30% -20% 58%; gap: 5px; opacity: .55; }
  .pub-banner-text { padding-block: .9rem; }
}
@media (min-width: 1800px) { .pub-banner-text { max-width: 1600px; } }

/* ---------- สรุปผู้ได้รับรางวัล (Phase 14) ---------- */
.pub-award-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: .8rem; }
.pub-award { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem .9rem; background: var(--surface); }
.pub-award h3 { font-size: 1.02rem; font-weight: 600; margin: 0; }
.pub-award h3 a { color: inherit; text-decoration: none; }
.pub-award-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; }
.pub-award-list li { display: grid; grid-template-columns: auto 1fr auto; gap: .6rem; align-items: center; }
.pub-award-who { line-height: 1.3; min-width: 0; overflow-wrap: anywhere; }
.pub-award-res { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }

/* ---------- สถิติโรงเรียน (Phase 15) ---------- */
.pub-record-badge { display: inline-block; font-size: .78rem; font-weight: 600; line-height: 1.2; padding: .12rem .45rem; border-radius: 999px;
  background: #FFF3C4; color: #7A4A00; border: 1px solid #F1C94B; white-space: nowrap; vertical-align: middle; }
.pub-record-new td { background: #FFFBEA; }

/* ---------- นักกีฬายอดเยี่ยม (Phase 15) ---------- */
.pub-best-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.pub-best-grid .pub-card { margin: 0; }
.pub-best-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.pub-best-list li { display: grid; grid-template-columns: 2.4rem 1fr; gap: .2rem .7rem; align-items: center; padding: .55rem .7rem;
  border-radius: var(--radius); border-left: 5px solid var(--house); background: var(--paper); }
.pub-best-1 { background: linear-gradient(90deg, #FFF6D6, var(--paper)) !important; }
.pub-best-rank { grid-row: span 2; font-family: var(--font-head); font-size: 1.4rem; font-weight: 700; text-align: center; }
.pub-best-who { min-width: 0; overflow-wrap: anywhere; }
.pub-best-medals { display: flex; flex-wrap: wrap; gap: .7rem; align-items: center; font-variant-numeric: tabular-nums; }
.pub-best-medals span { display: inline-flex; align-items: center; gap: .25rem; }

/* ---------- กราฟคะแนนสีเคลื่อนไหว (Phase 15) ---------- */
.pub-race-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .6rem; margin-bottom: .8rem; }
.pub-race-step { display: inline-block; font-variant-numeric: tabular-nums; color: var(--muted); margin-right: .5rem; }
.pub-race-event { font-family: var(--font-head); font-weight: 600; }
.pub-race-ctrl { display: flex; gap: .4rem; align-items: center; }
.pub-race-ctrl .form-select { width: auto; min-width: 5.5rem; }
.pub-race-stage { position: relative; }
.pub-race-row { position: absolute; left: 0; right: 0; top: 0; height: 56px; display: grid; grid-template-columns: minmax(84px, 9rem) 1fr 4.2rem 3.4rem;
  align-items: center; gap: .6rem; transition: transform .7s cubic-bezier(.3, .8, .3, 1); }
.pub-race-name { font-family: var(--font-head); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pub-race-track { height: 36px; background: var(--paper); border-radius: 8px; overflow: hidden; }
.pub-race-bar { display: block; height: 100%; width: 1.5%; background: var(--house); border-radius: 8px; transition: width .7s cubic-bezier(.3, .8, .3, 1);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .12); }
.pub-race-score { font-family: var(--font-head); font-weight: 700; font-size: 1.25rem; text-align: right; font-variant-numeric: tabular-nums; }
.pub-race-add { color: #1E6B48; font-weight: 600; font-size: .9rem; opacity: 0; }
.pub-race-add.pop { animation: pub-race-pop 1.2s ease-out forwards; }
@keyframes pub-race-pop { 0% { opacity: 0; transform: translateY(6px); } 25% { opacity: 1; transform: none; } 100% { opacity: .55; } }
@media (max-width: 575px) { .pub-race-row { grid-template-columns: 4.6rem 1fr 3.4rem; } .pub-race-add { display: none; } }
@media (prefers-reduced-motion: reduce) { .pub-race-row, .pub-race-bar { transition: none; } }

/* ---------- โลโก้โรงเรียนบนแบนเนอร์ (Phase 16) ---------- */
.pub-banner-default .pub-banner-text { display: flex; align-items: center; gap: clamp(.8rem, 2vw, 1.6rem); }
.pub-banner-logo { flex: none; width: clamp(76px, 10vw, 150px); aspect-ratio: 1; border-radius: 50%; background: #fff; padding: clamp(5px, .6vw, 9px);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, .22), 0 10px 28px rgba(0, 0, 0, .35); display: grid; place-items: center; overflow: hidden; }
.pub-banner-logo img { width: 100%; height: 100%; object-fit: contain; }
.pub-banner-default .pub-banner-lanes { inset: 7% -6% 7% 60%; gap: 7px; }
.pub-banner-default .pub-banner-lanes span { max-height: 28px; }
@media (max-width: 640px) { .pub-banner-logo { width: 64px; padding: 4px; } .pub-banner-default .pub-banner-lanes { inset: 4% -30% 4% 66%; gap: 4px; } }
