:root {
  --bg: #0b1220;
  --panel: #131c2e;
  --panel2: #1a2640;
  --line: #26344f;
  --text: #e8eefc;
  --muted: #8da0c4;
  --accent: #2ecc71;
  --accent-d: #1f9d55;
  --warn: #f5b942;
  --danger: #ef5b5b;
  --blue: #4c8dff;
  font-family: 'Sarabun', 'Noto Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-size: 16px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: #0e1628; position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; font-size: 18px; }
.brand span { color: var(--muted); font-weight: 500; font-size: 14px; margin-left: 4px; }
.who { margin-left: auto; color: var(--muted); font-size: 14px; text-align: right; }
.who b { color: var(--text); }
.conn { font-size: 12px; color: var(--danger); }
.conn.on { color: var(--accent); }

.turn { margin: 12px 16px; padding: 14px 16px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); }
.turn.mine { border-color: var(--accent); box-shadow: 0 0 0 2px #2ecc7133, 0 0 24px #2ecc7122; background: linear-gradient(180deg, #14301f, #131c2e); }
.turn .row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.turn .pills { display: flex; gap: 6px; }
.pill { padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); font-size: 13px; color: var(--muted); background: transparent; }
.pill.on { background: var(--panel2); color: var(--text); border-color: var(--blue); }
.who-turn { flex: 1 1 260px; min-width: 0; }
.who-turn .label { color: var(--muted); font-size: 13px; }
.who-turn .name { font-size: 24px; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.who-turn .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.clock { text-align: center; min-width: 120px; }
.clock .t { font-size: 48px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; color: var(--accent); }
.clock.low .t { color: var(--warn); }
.clock.crit .t { color: var(--danger); animation: pulse 0.8s infinite; }
.clock.paused .t { color: var(--muted); }
@keyframes pulse { 50% { opacity: 0.45; } }
.bar { height: 6px; background: #0b1220; border-radius: 6px; margin-top: 10px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.25s linear; }
.upnext { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; font-size: 13px; color: var(--muted); align-items: center; }
.chip { padding: 2px 8px; border-radius: 8px; background: var(--panel2); border: 1px solid var(--line); color: var(--text); font-size: 13px; }
.chip.me { border-color: var(--accent); color: var(--accent); }
.chip.retry { border-style: dashed; }

.tabs { display: flex; gap: 4px; padding: 0 16px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }

main { padding: 14px 16px 60px; }
.panel { display: none; }
.panel.on { display: block; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.card h3 { margin: 0 0 8px; font-size: 15px; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.filters input[type=search], .filters select { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; min-width: 0; }
.filters input[type=search] { flex: 1 1 220px; }
label.chk { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }

.plist { display: grid; gap: 6px; }
.prow { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.prow .star { background: none; border: 0; font-size: 20px; color: var(--muted); padding: 0 4px; }
.prow .star.on { color: var(--warn); }
.prow .nm { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.prow .nm small { display: block; color: var(--muted); font-size: 12px; }

.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; }
.btn:hover { border-color: var(--blue); }
.btn.primary { background: var(--accent-d); border-color: var(--accent); font-weight: 600; }
.btn.primary:disabled { background: var(--panel2); border-color: var(--line); color: var(--muted); cursor: not-allowed; }
.btn.warn { border-color: var(--warn); color: var(--warn); }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.team { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.team.cur { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.team.me { background: #15233d; }
.team h4 { margin: 0 0 6px; font-size: 15px; display: flex; justify-content: space-between; gap: 8px; }
.team h4 .cnt { color: var(--muted); font-weight: 500; font-size: 13px; white-space: nowrap; }
.team h4 .cnt.ok { color: var(--accent); }
.team ul { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.team li { padding: 2px 0; display: flex; justify-content: space-between; gap: 6px; border-top: 1px dashed #1f2c47; }
.team li span:last-child { color: var(--muted); font-size: 12px; white-space: nowrap; }
.team .empty { color: var(--muted); font-size: 13px; }

.log { font-size: 14px; display: grid; gap: 4px; }
.log div { padding: 6px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.log time { color: var(--muted); margin-right: 8px; font-variant-numeric: tabular-nums; font-size: 12px; }

.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.order { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px; font-size: 14px; margin-top: 8px; }
.order div { background: var(--panel2); border-radius: 8px; padding: 3px 8px; }
.order b { color: var(--accent); margin-right: 6px; }
.field { display: grid; gap: 4px; margin: 8px 0; }
.field input, .field select { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.field.inline { grid-template-columns: 1fr 1fr; gap: 8px; }
.linkrow { display: flex; gap: 6px; align-items: center; font-size: 13px; padding: 4px 0; border-top: 1px dashed var(--line); }
.linkrow span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.modal { position: fixed; inset: 0; background: #000a; display: grid; place-items: center; z-index: 20; padding: 16px; }
.modal[hidden], .toast[hidden] { display: none; }
.modal .box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; width: min(420px, 100%); }
.modal h3 { margin: 0 0 8px; }
.modal .btns { justify-content: flex-end; margin-top: 14px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #223152; border: 1px solid var(--blue); padding: 10px 16px; border-radius: 10px; z-index: 30; max-width: 90vw; }
.toast.err { border-color: var(--danger); background: #3a1f25; }

@media (max-width: 560px) {
  .clock .t { font-size: 40px; }
  .who-turn .name { font-size: 20px; }
}

/* ---------- แอนิเมชันจับฉลาก ---------- */
.lotto { position: fixed; inset: 0; z-index: 40; background: radial-gradient(circle at 50% 20%, #12305a, #050a14 70%); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.lotto[hidden] { display: none; }
.lbox { width: min(980px, 100%); }
.lbox h2 { text-align: center; margin: 0 0 14px; font-size: 26px; letter-spacing: 0.5px; }
.lbox .sub { text-align: center; color: var(--muted); margin: -6px 0 14px; }
.lgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.lslot { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: #0e1830; border: 1px solid var(--line); min-height: 52px; }
.lslot b { min-width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: #1b2a4a; color: var(--muted); font-size: 16px; }
.lslot span { flex: 1; min-width: 0; overflow-wrap: anywhere; color: var(--muted); font-size: 16px; }
.lslot.spin { border-color: var(--warn); box-shadow: 0 0 18px #f5b94255; animation: lspin 0.25s infinite alternate; }
.lslot.spin b { background: var(--warn); color: #111; }
.lslot.spin span { color: var(--warn); font-weight: 700; filter: blur(0.4px); }
.lslot.done { border-color: var(--accent); background: #12301f; animation: lpop 0.5s ease-out; }
.lslot.done b { background: var(--accent); color: #06210f; }
.lslot.done span { color: var(--text); font-weight: 700; }
.lslot.mine.done { background: #1b5a33; box-shadow: 0 0 0 2px var(--accent), 0 0 24px #2ecc7166; }
@keyframes lspin { from { transform: translateY(-1px); } to { transform: translateY(1px); } }
@keyframes lpop { 0% { transform: scale(1.12); box-shadow: 0 0 30px #2ecc71aa; } 100% { transform: scale(1); } }
.lbtns { text-align: center; margin-top: 16px; }
@media (prefers-reduced-motion: reduce) { .lslot.spin, .lslot.done { animation: none; } }
