/* ===== SportDay Live ===== */
:root {
  --bg: #0b0d12;
  --panel: #141821;
  --panel-2: #1b2130;
  --line: #283044;
  --text: #eef1f6;
  --muted: #8a93a8;
  --red: #ff3b30;
  --ok: #30d158;
  --warn: #ffd60a;
  --primary: #3d7bff;
  --radius: 14px;
  --font: 'Kanit', 'Sukhumvit Set', 'Thonburi', 'Leelawadee UI', 'Noto Sans Thai', system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
kbd { font-family: inherit; font-size: 12px; padding: 1px 7px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; color: var(--muted); }

.btn {
  font: inherit; font-weight: 500; font-size: 15px; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 16px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .15s, transform .08s, border-color .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: #232a3c; }
.btn:active { transform: scale(.97); }
.btn:focus-visible, .seg-btn:focus-visible, .score-ctl button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: #5a8fff; }
.btn-danger { background: #3a1418; border-color: #6b2128; color: #ffb3ae; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-lg { padding: 15px 18px; font-size: 18px; }
.btn-sm { padding: 6px 12px; font-size: 14px; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 99px; background: rgba(20, 24, 33, .78); border: 1px solid var(--line); font-size: 14px; white-space: nowrap; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.pill-bad { background: #4a1216; border-color: #8b1d24; color: #ffd2cf; }

.field { display: grid; gap: 6px; }
.field > span { font-size: 14px; color: var(--muted); }
.field input {
  font: inherit; font-size: 17px; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; width: 100%;
}
.field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(61, 123, 255, .25); }
.error { color: #ff8a80; margin: 4px 0; }
.checks { list-style: none; margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); display: grid; gap: 4px; font-size: 14px; }
.checks .ok { color: var(--ok); }
.checks .bad { color: #ff8a80; }
.link-muted { color: var(--muted); text-decoration: none; font-size: 14px; }

/* โลโก้ 4 แถบสี */
.brand-mark { display: inline-grid; grid-template-columns: repeat(4, 1fr); gap: 3px; width: 34px; height: 34px; transform: skewX(-12deg); }
.brand-mark i { border-radius: 3px; }
.brand-mark i:nth-child(1) { background: #e53935; }
.brand-mark i:nth-child(2) { background: #29b6f6; }
.brand-mark i:nth-child(3) { background: #43a047; }
.brand-mark i:nth-child(4) { background: #8e24aa; }
.brand-mark.big { width: 120px; height: 120px; gap: 10px; }
.brand-mark.big i { border-radius: 8px; }

/* โลโก้งาน (ออกแบบมาบนพื้นขาว จึงวางบนแผ่นขาวมุมมน) */
.logo { display: block; flex: none; height: 46px; width: auto; aspect-ratio: 638 / 454; padding: 3px 5px; border-radius: 10px; background: #fff; object-fit: contain; }
.logo-big { height: 150px; padding: 8px 12px; border-radius: 18px; }
.home-head .logo, .login-card .logo { height: 64px; }
.login-card .logo { justify-self: start; }

/* segmented radio */
.seg { border: 0; padding: 0; margin: 0 0 18px; display: flex; flex-wrap: wrap; gap: 8px; }
.seg legend { font-size: 14px; color: var(--muted); margin-bottom: 8px; padding: 0; }
.seg label { flex: 1 1 0; min-width: 96px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label span { display: block; text-align: center; padding: 11px 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; }
.seg input:checked + span { border-color: var(--primary); background: rgba(61, 123, 255, .16); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ===== หน้าแรก / login ===== */
.home, .login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(380px, 100%); display: grid; gap: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 28px; }
.login-card h1 { margin: 6px 0 0; font-size: 24px; }
.login-card p { margin: 0; }
.home-wrap { width: min(980px, 100%); }
.home-head { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.home-head h1 { margin: 0; font-size: clamp(24px, 4vw, 34px); line-height: 1.2; }
.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.home-card { display: grid; gap: 8px; align-content: start; padding: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; color: inherit; text-decoration: none; transition: border-color .15s, transform .15s; }
.home-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.home-card .num { font-size: 13px; color: var(--muted); letter-spacing: .08em; }
.home-card h2 { margin: 0; font-size: 22px; }
.home-card p { margin: 0; color: var(--muted); line-height: 1.55; }
.home-flow { margin: 26px 0 0; padding: 18px 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; line-height: 1.7; color: var(--muted); }
.home-flow b { color: var(--text); }
.home-flow code { color: var(--text); background: var(--bg); padding: 2px 7px; border-radius: 6px; font-size: 14px; word-break: break-all; }
.home-flow ol { margin: 6px 0 0; padding-left: 20px; }

/* ===== หน้าผู้ปกครอง ===== */
.page-watch { min-height: 100dvh; }
.w-head { display: flex; align-items: center; gap: 12px; width: min(960px, 100%); margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 16px 12px; }
.w-head h1 { margin: 0; font-size: clamp(19px, 3.6vw, 28px); line-height: 1.25; }
.w-main { width: min(960px, 100%); margin: 0 auto; padding: 0 16px 40px; display: grid; gap: 14px; }
.w-player { position: relative; aspect-ratio: 16 / 9; border-radius: 16px; overflow: hidden; background: #05070b; border: 1px solid var(--line); }
.w-player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.w-wait { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 4px; text-align: center; padding: 16px;
  background: radial-gradient(circle at 50% 40%, #16203a, #05070b 75%); }
.w-wait .logo-big { height: 110px; margin-bottom: 12px; }
.w-wait p { margin: 0; font-size: 18px; }
.w-wait p.small { font-size: 14px; }
.w-staff { text-align: center; margin: 6px 0 0; }
.w-closed { padding: 22px 18px; text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; }
.w-closed h2 { margin: 0 0 6px; font-size: 20px; font-weight: 600; }
.w-closed p { margin: 0; line-height: 1.6; }
.is-closed .w-player, .is-closed .w-now, .is-closed .w-ticker, .is-closed .w-board { display: none !important; }
.w-now { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.w-live { display: inline-flex; align-items: center; gap: 7px; flex: none; padding: 4px 12px; border-radius: 99px; background: var(--red); color: #fff; font-weight: 600; font-size: 14px; }
.w-live .dot { width: 8px; height: 8px; border-radius: 50%; background: #fff; animation: pulse 1.6s ease-in-out infinite; }
.w-title { font-size: 20px; font-weight: 600; line-height: 1.3; }
.w-sub { color: var(--warn); }
.w-sub:empty { display: none; }
.w-ticker { padding: 12px 16px; border-radius: 14px; background: rgba(255, 214, 10, .1); border: 1px solid rgba(255, 214, 10, .35); line-height: 1.6; }
.w-board { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.w-board h2 { margin: 0 0 12px; font-size: 18px; font-weight: 600; }
.w-board p { margin: 12px 0 0; }
.w-scores { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.w-scores li { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--bg); border-left: 8px solid var(--c); }
.w-scores li.lead { background: color-mix(in srgb, var(--c) 22%, var(--bg)); }
.w-rank { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--panel-2); font-weight: 600; font-size: 15px; }
.w-scores li.lead .w-rank { background: var(--warn); color: #1a1500; }
.w-name { font-size: 18px; }
.w-val { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.w-scores li.bump .w-val { animation: bump .6s cubic-bezier(.2, .9, .3, 1.4); }

/* ===== หน้ากล้อง ===== */
.page-camera { background: #000; overflow: hidden; height: 100dvh; }
#local { position: fixed; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
#local.mirror { transform: scaleX(-1); }
.tally { position: fixed; inset: 0; pointer-events: none; border: 6px solid transparent; transition: border-color .2s; z-index: 2; }
.on-air .tally { border-color: var(--red); }
.cam-top { position: fixed; z-index: 3; top: max(10px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right)); display: flex; flex-wrap: wrap; gap: 6px; }
.on-air .pill-air { background: var(--red); border-color: var(--red); color: #fff; font-weight: 600; }
.cam-controls { position: fixed; z-index: 3; bottom: max(12px, env(safe-area-inset-bottom)); right: max(12px, env(safe-area-inset-right)); display: flex; gap: 8px; }
.cam-controls .btn { backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); background: rgba(20, 24, 33, .78); }
.cam-controls .btn-danger { background: rgba(80, 18, 24, .85); }
.rotate-hint { display: none; }
@media (orientation: portrait) {
  .page-camera:not(:has(.setup:not([hidden]))) .rotate-hint {
    display: block; position: fixed; z-index: 3; left: 50%; bottom: 90px; transform: translateX(-50%);
    background: rgba(255, 214, 10, .95); color: #1a1500; padding: 10px 16px; border-radius: 12px; text-align: center; width: max-content; max-width: calc(100% - 32px);
  }
}
.setup { position: fixed; inset: 0; z-index: 4; overflow-y: auto; background: var(--bg); padding: 24px 16px; display: grid; place-items: center; }
.setup-card { width: min(460px, 100%); }
.setup-card h1 { margin: 0; font-size: 26px; }
.setup-card > p.muted { margin: 2px 0 22px; }
.hint { font-size: 14px; color: var(--muted); line-height: 1.6; }

/* ===== หน้าแอดมิน ===== */
.page-admin { padding-bottom: 40px; }
.adm-head { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 12px max(16px, env(safe-area-inset-left)); background: rgba(11, 13, 18, .9); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.adm-brand { display: flex; align-items: center; gap: 12px; }
.adm-title { font-size: 20px; font-weight: 600; }
.adm-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.adm { width: min(1280px, 100%); margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 18px; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.panel-head h2 { margin: 0; font-size: 19px; font-weight: 600; }
.seg-inline { margin: 0; gap: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 11px; padding: 3px; }
.seg-btn { font: inherit; font-size: 15px; color: var(--muted); background: transparent; border: 0; border-radius: 8px; padding: 8px 14px; cursor: pointer; }
.seg-btn.active { background: var(--panel-2); color: var(--text); box-shadow: 0 1px 0 rgba(255, 255, 255, .06) inset; }
.seg-btn[data-mode="live"].active { background: var(--red); color: #fff; }

.cams { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.cam-card { border: 2px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--bg); transition: border-color .2s, box-shadow .2s; }
.cam-card.on-air { border-color: var(--red); box-shadow: 0 0 0 4px rgba(255, 59, 48, .18); }
.cam-view { position: relative; aspect-ratio: 16 / 9; background: #05070a; cursor: pointer; }
.cam-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-card:not([data-status="live"]) .cam-view video { opacity: .25; }
.cam-status { position: absolute; left: 10px; bottom: 10px; font-size: 13px; padding: 3px 10px; border-radius: 99px; background: rgba(0, 0, 0, .65); }
.cam-status::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--muted); vertical-align: 1px; }
.cam-card[data-status="live"] .cam-status::before { background: var(--ok); }
.cam-card[data-status="connecting"] .cam-status::before { background: var(--warn); }
.cam-help { position: absolute; inset: 0; display: none; flex-direction: column; justify-content: center; align-items: center; gap: 10px; padding: 36px 12px; text-align: center; font-size: 14px; color: var(--muted); }
.cam-help code, .cam-link code { color: var(--text); background: var(--panel-2); padding: 1px 7px; border-radius: 5px; word-break: break-all; font-size: 14px; letter-spacing: .05em; }
.cam-card[data-status="offline"] .cam-help { display: flex; }
.cam-link { margin: -4px 0 14px; line-height: 1.7; }
.cam-help .btn { pointer-events: auto; }
.cam-local-ctl { position: absolute; top: 10px; right: 10px; display: none; gap: 6px; }
.cam-local-ctl .btn { background: rgba(10, 12, 18, .75); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.cam-local-ctl .btn-danger { background: rgba(80, 18, 24, .85); }
.cam-card[data-status="local"] .cam-local-ctl { display: flex; }
.cam-card[data-status="local"] .cam-status::before { background: var(--primary); }
.cam-onair { position: absolute; top: 10px; left: 10px; font-size: 13px; font-weight: 700; letter-spacing: .08em; padding: 3px 10px; border-radius: 6px; background: var(--red); color: #fff; display: none; }
.cam-card.on-air .cam-onair { display: block; }
.cam-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; }
.btn-take { min-width: 120px; }
.cam-foot { flex-wrap: wrap; }
.cam-name { white-space: nowrap; }
.cam-btns { display: flex; gap: 6px; flex: none; margin-left: auto; }
.btn-pip { padding-inline: 12px; }
.cam-card.in-pip { border-color: #e5e7eb; }
.cam-card.in-pip .btn-pip { background: #e5e7eb; border-color: #e5e7eb; color: #111; }
.public-toggle { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 12px 14px; margin-bottom: 14px; border-radius: 12px; border: 1px solid rgba(48, 209, 88, .35); background: rgba(48, 209, 88, .08); }
.public-toggle.is-off { border-color: var(--line); background: var(--bg); }
.switch-lg span { font-weight: 600; font-size: 16px; }
.yt-row { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 10px; }
#ytStatus { margin: 10px 0 0; }
.pip-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 14px 0 6px; }
.seg-btn[data-pip-pos].active { background: #e5e7eb; color: #111; }
.seg-btn:disabled, .btn-pip:disabled { opacity: .4; pointer-events: none; }
.cam-card.on-air .btn-take { background: var(--red); border-color: var(--red); color: #fff; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-wide { grid-column: 1 / -1; }
.form-row { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; }
.form-row .btn { margin-left: auto; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { appearance: none; -webkit-appearance: none; width: 44px; height: 26px; border-radius: 99px; background: var(--line); position: relative; cursor: pointer; transition: background .2s; margin: 0; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked { background: var(--ok); }
.switch input:checked::after { transform: translateX(18px); }
.switch input:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.scores { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.score-ctl { border-radius: 14px; background: var(--bg); border: 1px solid var(--line); border-top: 6px solid var(--c); padding: 14px; display: grid; gap: 8px; }
.score-ctl-name { font-weight: 500; }
.score-ctl-val { font: inherit; font-size: 46px; font-weight: 700; line-height: 1; text-align: left; color: var(--text); background: none; border: 0; padding: 4px 0; cursor: pointer; font-variant-numeric: tabular-nums; }
.score-ctl-btns { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.score-ctl-btns button { font: inherit; font-size: 15px; font-weight: 500; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 10px 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.score-ctl-btns button:active { transform: scale(.94); background: color-mix(in srgb, var(--c) 35%, var(--panel-2)); }
.cam-settings summary { list-style: none; cursor: pointer; display: grid; gap: 2px; }
.cam-settings summary::-webkit-details-marker { display: none; }
.cam-settings summary h2 { margin: 0; font-size: 19px; font-weight: 600; }
.cam-settings summary h2::after { content: ' ▸'; color: var(--muted); }
.cam-settings[open] summary h2::after { content: ' ▾'; }
.cam-settings[open] summary { margin-bottom: 16px; }
.users { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 6px; }
.users li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); }
.acc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.acc-form { display: grid; gap: 10px; align-content: start; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); }
.acc-form h3 { margin: 0; font-size: 16px; font-weight: 600; }
.acc-form .btn { justify-self: start; }
.cs-table { display: grid; gap: 10px; }
.cs-row { display: grid; grid-template-columns: 32px 1fr 150px auto auto; align-items: end; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.cs-num { align-self: center; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--panel-2); font-weight: 600; }
.cs-pin { font-variant-numeric: tabular-nums; letter-spacing: .12em; }
.cs-actions { display: flex; justify-content: space-between; gap: 10px; margin: 14px 0 4px; }
@media (max-width: 640px) {
  .cs-row { grid-template-columns: 32px 1fr 1fr; }
  .cs-row .btn { grid-column: span 1; }
  .cs-row .cs-rand { grid-column: 2; }
}
.toast { position: fixed; z-index: 10; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); background: #f2f4f8; color: #111; padding: 10px 18px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-row .btn { margin-left: 0; width: 100%; }
}

/* ===== จอ LED (เวที 1920×1080 คงที่ แล้ว scale ให้พอดีจอ) ===== */
.page-display { background: #000; overflow: hidden; height: 100dvh; }
.page-display.idle { cursor: none; }
.stage { position: absolute; left: 50%; top: 50%; width: 1920px; height: 1080px; transform-origin: center center; overflow: hidden; background: #05070b; }
.feed { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .35s ease; background: #000; }
.feed.on { opacity: 1; }

/* ภาพซ้อนจอเล็ก (PiP) 560×315 */
.pip { position: absolute; width: 560px; height: 315px; border-radius: 14px; overflow: hidden; background: #000;
  border: 4px solid rgba(255, 255, 255, .9); box-shadow: 0 16px 40px rgba(0, 0, 0, .55);
  opacity: 0; transform: scale(.92); transition: opacity .35s, transform .35s; pointer-events: none; z-index: 1; }
.pip.on { opacity: 1; transform: scale(1); }
.pip video { width: 100%; height: 100%; object-fit: cover; display: block; }
.pip-label { position: absolute; left: 10px; bottom: 10px; padding: 4px 12px; border-radius: 8px; background: rgba(8, 10, 16, .8); font-size: 22px; font-weight: 500; }
.pip.pos-tr { top: 130px; right: 52px; transform-origin: top right; }
.pip.pos-tl { top: 200px; left: 52px; transform-origin: top left; }
.pip.pos-br { bottom: 220px; right: 52px; transform-origin: bottom right; }
.pip.pos-bl { bottom: 220px; left: 52px; transform-origin: bottom left; }
.nosignal { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 28px; background: radial-gradient(circle at 50% 40%, #16203a, #05070b 70%); opacity: 0; transition: opacity .4s; pointer-events: none; }
.nosignal.on { opacity: 1; }
.nosignal .logo-big { height: 300px; padding: 16px 24px; border-radius: 28px; }
.ns-event { font-size: 64px; font-weight: 700; }
.ns-msg { font-size: 34px; color: var(--muted); }
.ns-msg::after { content: ''; animation: dots 1.4s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

.standby { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; text-align: center; padding: 80px; gap: 10px; opacity: 0; pointer-events: none; transition: opacity .5s;
  background:
    linear-gradient(180deg, rgba(5, 7, 11, 0) 70%, rgba(5, 7, 11, .9)),
    radial-gradient(circle at 50% 30%, #1a2542, #05070b 75%); }
.is-standby .standby { opacity: 1; }
.sb-logo { height: 220px; padding: 12px 18px; border-radius: 24px; margin-bottom: 18px; }
.sb-school { font-size: 40px; color: var(--muted); }
.sb-event { margin: 0; font-size: 104px; font-weight: 800; line-height: 1.1; letter-spacing: -.01em; }
.sb-title { font-size: 46px; color: var(--warn); min-height: 60px; margin-bottom: 40px; }
.sb-scores { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 24px; width: 1600px; }

.bug { position: absolute; top: 44px; left: 52px; display: flex; align-items: stretch; max-width: 1300px; transition: opacity .4s, transform .4s; filter: drop-shadow(0 10px 30px rgba(0, 0, 0, .5)); }
.is-standby .bug, .is-standby .clock, .is-standby .lower { opacity: 0; transform: translateY(-10px); }
.bug-logo { display: block; width: auto; height: auto; max-height: 132px; align-self: stretch; aspect-ratio: 638 / 454; object-fit: contain; padding: 8px 10px; background: #fff; border-radius: 12px 0 0 12px; }
.bug-live { display: flex; align-items: center; gap: 12px; padding: 0 24px; background: var(--red); color: #fff; font-size: 32px; font-weight: 700; letter-spacing: .06em; }
.bug-live .dot { width: 16px; height: 16px; border-radius: 50%; background: #fff; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.bug-text { padding: 12px 28px 14px; background: rgba(8, 10, 16, .82); border-radius: 0 12px 12px 0; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.bug-event { font-size: 26px; color: #c8cfdd; }
.bug-title { font-size: 46px; font-weight: 700; line-height: 1.15; }
.bug-sub { font-size: 28px; color: var(--warn); }
.bug-sub:empty, .bug-title:empty { display: none; }
.bug.no-title .bug-event { font-size: 34px; color: #fff; font-weight: 600; }

.clock { position: absolute; top: 44px; right: 52px; font-size: 40px; font-weight: 600; padding: 10px 24px; border-radius: 12px; background: rgba(8, 10, 16, .78); font-variant-numeric: tabular-nums; transition: opacity .4s, transform .4s; }

.lower { position: absolute; left: 52px; right: 52px; bottom: 40px; display: grid; gap: 12px; transition: opacity .4s, transform .4s; }
.lower.hide { opacity: 0; }
.scorebar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 14px; transition: opacity .3s; }
.scorebar.hide { display: none; }
.score-card { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 26px; border-radius: 14px; background: rgba(8, 10, 16, .84); border-left: 12px solid var(--c); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); filter: drop-shadow(0 8px 24px rgba(0, 0, 0, .45)); }
.score-card .sc-name { font-size: 32px; font-weight: 500; }
.score-card .sc-val { font-size: 60px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.score-card.lead { background: linear-gradient(90deg, color-mix(in srgb, var(--c) 38%, rgba(8, 10, 16, .88)), rgba(8, 10, 16, .88)); }
.score-card.lead .sc-name::after { content: ' ▲ นำ'; font-size: 22px; color: var(--warn); }
.score-card.bump .sc-val { animation: bump .6s cubic-bezier(.2, .9, .3, 1.4); }
@keyframes bump { 0% { transform: scale(1); } 35% { transform: scale(1.35); color: var(--warn); } 100% { transform: scale(1); } }
.score-card.big { flex-direction: column; justify-content: center; padding: 34px 20px 38px; border-left: 0; border-top: 16px solid var(--c); background: rgba(14, 18, 28, .9); }
.score-card.big .sc-name { font-size: 44px; }
.score-card.big .sc-val { font-size: 150px; }

.ticker { display: flex; align-items: stretch; height: 66px; border-radius: 12px; overflow: hidden; background: rgba(8, 10, 16, .88); }
.ticker.hide { display: none; }
.ticker-label { display: flex; align-items: center; padding: 0 24px; background: var(--warn); color: #1a1500; font-size: 28px; font-weight: 700; flex: none; }
.ticker-win { position: relative; flex: 1; overflow: hidden; display: flex; align-items: center; }
.ticker-track { display: inline-block; white-space: nowrap; padding-left: 100%; font-size: 32px; will-change: transform; }
@keyframes ticker { from { transform: translateX(0); } to { transform: translateX(-100%); } }

.start-overlay { position: fixed; inset: 0; z-index: 20; display: grid; place-content: center; gap: 12px; text-align: center; border: 0; color: #fff; font: inherit; cursor: pointer; background: rgba(0, 0, 0, .72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.so-title { font-size: clamp(24px, 4vw, 44px); font-weight: 700; }
.so-sub { font-size: clamp(14px, 1.8vw, 20px); color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .ticker-track { animation-duration: 40s !important; animation-iteration-count: infinite !important; }
}
