:root{
  --bg1:#e9fff3;
  --bg2:#dff7ea;
  --line:rgba(16,24,40,.10);
  --shadow: 0 16px 40px rgba(16,24,40,.10);
  --shadow2: 0 10px 26px rgba(16,24,40,.08);

  --text:#0f172a;
  --muted:rgba(15,23,42,.68);

  --brand:#2bbf6a;
  --brand2:#1f6f3a;

  --danger:#ff4d6d;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: "Kanit","Prompt",system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  color:var(--text);
  background:
    radial-gradient(1200px 600px at 20% 10%, rgba(43,191,106,.18), transparent 60%),
    radial-gradient(1000px 520px at 90% 0%, rgba(16,185,129,.14), transparent 58%),
    linear-gradient(180deg, var(--bg1), var(--bg2));
}

.wrap{ max-width: 1200px; margin: 0 auto; padding: 18px; }
@media(max-width: 980px){ .wrap{ padding: 14px; } }

.topbar{
  position: sticky; top:0; z-index: 50;
  display:flex; align-items:center; justify-content:space-between;
  gap: 12px; padding: 12px 16px;
  background: rgba(255,255,255,.78);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand{ display:flex; gap:12px; align-items:center; min-width: 240px; }
.brandMark{
  width:42px;height:42px; 
  display:grid; place-items:center;
  background: linear-gradient(135deg, var(--brand2), var(--brand));
  box-shadow: 0 10px 22px rgba(16,24,40,.14);
  overflow:hidden;
}
.brandMark img{ width:100%; height:100%; object-fit:cover; display:block; }
.brandTitle{font-weight:900; letter-spacing:.2px}
.brandSub{font-size:12px; color:rgba(15,23,42,.65); margin-top:2px}

.topActions{
  display:flex; gap:10px; flex-wrap:wrap;
  align-items:center; justify-content:flex-end;
}
@media(max-width: 720px){
  .topbar{ align-items:flex-start; }
  .brand{ min-width: auto; }
  .topActions{ justify-content:flex-start; }
}

.btn{
  appearance:none;
  border:1px solid rgba(43,191,106,.22);
  background: linear-gradient(180deg, rgba(43,191,106,.95), rgba(31,111,58,.95));
  color:#fff; font-weight:900;
  padding: 10px 14px; border-radius: 14px;
  cursor:pointer;
  box-shadow: 0 10px 22px rgba(16,24,40,.10);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.btn:hover{ transform: translateY(-1px); filter: brightness(1.02); }
.btn.ghost{
  background: rgba(255,255,255,.90);
  color: var(--brand2);
  border: 1px solid rgba(16,185,129,.30);
  box-shadow: 0 10px 20px rgba(16,24,40,.06);
}
.btn.danger{
  background: linear-gradient(180deg, rgba(255,77,109,.95), rgba(180,35,24,.92));
  border: 1px solid rgba(255,77,109,.25);
}
.btn.mini{ padding: 8px 10px; border-radius: 12px; font-size: 12px; }
a.btn{ text-decoration:none; display:inline-flex; align-items:center; justify-content:center; }

select, input{
  width:100%;
  padding: 10px 12px;
  border-radius: 14px;
  border:1px solid rgba(16,185,129,.25);
  background: rgba(255,255,255,.92);
  color: var(--text);
  outline:none;
}
@media(max-width: 860px){ input,select{ font-size:16px; } }

.card{
  background: rgba(255,255,255,.88);
  border: 1px solid rgba(16,185,129,.18);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 18px;
}
.cardHead{
  display:flex; align-items:center; justify-content:space-between;
  gap:10px; flex-wrap:wrap;
}
.h2{ font-size:18px; margin:0; font-weight: 900; }
.muted{ color: var(--muted); font-size: 13px; }
.mutedTiny{ color: rgba(15,23,42,.62); font-size:12px; }

.badge{
  padding: 6px 10px;
  border-radius: 999px;
  font-weight:900;
  font-size: 12px;
  color: var(--brand2);
  background: rgba(16,185,129,.12);
  border:1px solid rgba(16,185,129,.25);
}
.pill{
  display:inline-flex; align-items:center; justify-content:center;
  padding: 10px 12px; border-radius: 14px;
  background: rgba(16,185,129,.10);
  border:1px solid rgba(16,185,129,.25);
  font-weight:900; color: var(--brand2);
}

/* tables */
.tableWrap{
  width: 100%;
  overflow:auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 16px;
}
table{
  width:100%;
  border-collapse: separate;
  border-spacing: 0;
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(16,185,129,.18);
  border-radius: 16px;
  overflow:hidden;
  min-width: 980px; /* กันบีบจนปุ่มหาย */
}
@media(max-width: 980px){
  table{ min-width: 980px; } /* มือถือเลื่อนข้าง */
}
thead th{
  position: sticky; top: 0; z-index: 1;
  background: linear-gradient(180deg, rgba(31,111,58,.95), rgba(43,191,106,.92));
  color:#fff; font-weight: 900;
  text-align:left; padding: 12px 12px; font-size: 12px;
}
tbody td{ padding: 12px 12px; border-top: 1px solid rgba(16,185,129,.12); font-size: 13px; }
tbody tr:hover{ background: rgba(16,185,129,.06); }
.num{ text-align:right; font-variant-numeric: tabular-nums; }
.wideTeam{ min-width: 220px; }
tbody td:last-child{ overflow: visible; }

/* withdrawn row = จาง ๆ */
.rowWithdraw{ opacity:.45; filter: grayscale(.15); }

/* modal */
.modal{ position:fixed; inset:0; display:none; z-index:9999; }
.modal.show{ display:block; }
.modalBackdrop{ position:absolute; inset:0; background: rgba(15,23,42,.45); backdrop-filter: blur(2px); }
.modalPanel{
  position:relative;
  width:min(720px, calc(100% - 22px));
  margin: 18px auto;
  background: rgba(255,255,255,.95);
  border: 1px solid rgba(16,185,129,.22);
  border-radius: 22px;
  box-shadow: 0 22px 60px rgba(16,24,40,.20);
  padding: 16px 16px 18px;
}
.modalHead{
  display:flex; justify-content:space-between; align-items:flex-start;
  gap:10px; flex-wrap:wrap;
}
.modalTitle{ font-weight:900; font-size:18px; }
.modalActions{ display:flex; gap:10px; justify-content:flex-end; flex-wrap:wrap }

.form{ width:100%; }
.split2{ display:grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media(max-width: 860px){ .split2{ grid-template-columns: 1fr; } }
label{ display:block; font-weight:900; font-size:12px; margin: 10px 0 6px; color: rgba(15,23,42,.75); }

/* toast */
.toast{
  position: fixed; left: 50%; bottom: 18px;
  transform: translateX(-50%);
  background: rgba(15,23,42,.92);
  color: #fff;
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 10000;
}
.toast.show{ opacity: 1; transform: translateX(-50%) translateY(-2px); }

/* dashboard helpers (ถ้าต้องใช้) */
.kpis{ margin-top: 12px; display:grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap:12px; }
.kpi{
  background: rgba(255,255,255,.95);
  border: 1px solid rgba(16,185,129,.18);
  border-radius: 18px;
  padding: 12px;
  box-shadow: var(--shadow2);
}
.kpi .k{ font-size: 12px; color: rgba(15,23,42,.65); font-weight:900;}
.kpi .v{ font-size: 22px; font-weight: 900; margin-top: 4px; color: var(--brand2); }
@media(max-width: 980px){ .kpis{ grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media(max-width: 420px){ .kpis{ grid-template-columns: 1fr; } }



.chartBox{ position: relative; height: 260px; }
@media(max-width: 520px){ .chartBox{ height: 240px; } }



.chartBox{
  
  margin-top: 14px;
  background: rgba(255,255,255,.95);
  border: 1px solid rgba(16,185,129,.18);
  border-radius: 18px;
  padding: 12px;
  box-shadow: var(--shadow2);
  overflow:hidden;
}

.split{ display:grid; grid-template-columns: 1fr 1fr; gap:12px; margin-top: 12px; }
@media(max-width: 980px){ .split{ grid-template-columns: 1fr; } }
.miniCard{
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(16,185,129,.18);
  border-radius: 18px;
  padding: 12px;
  box-shadow: var(--shadow2);
}
.miniTitle{ font-weight: 900; margin-bottom: 8px; }
.miniList{ display:flex; flex-direction:column; gap:8px; }
.miniRow{
  display:flex; align-items:center; justify-content:space-between;
  gap:10px; padding: 10px 12px;
  border-radius: 14px;
  background: rgba(16,185,129,.08);
  border: 1px solid rgba(16,185,129,.18);
}
.hide-summary{ display:none !important; }
/* ================= SMS Report Scroll ================= */
.reportScroll{
  max-height: 320px;          /* ปรับได้: 260/320/420 */
  overflow: auto;             /* ⬅️➡️ + ⬆️⬇️ */
  padding: 10px;
  border-radius: 14px;
  border: 1px solid rgba(16,185,129,.18);
  background: rgba(255,255,255,.85);
  scrollbar-gutter: stable both-edges;
  -webkit-overflow-scrolling: touch;
}

/* scrollbar (Chrome/Edge) */
.reportScroll::-webkit-scrollbar{ width:8px; height:8px; }
.reportScroll::-webkit-scrollbar-thumb{
  background: linear-gradient(180deg,#2bbf6a,#1f6f3a);
  border-radius: 999px;
}
.reportScroll::-webkit-scrollbar-track{
  background: rgba(16,185,129,.12);
  border-radius: 999px;
}

/* Firefox */
.reportScroll{
  scrollbar-width: thin;
  scrollbar-color: #2bbf6a rgba(16,185,129,.12);
}
#smsReport{
  white-space: pre-wrap;      /* ขึ้นบรรทัดใหม่ได้ */
  word-break: break-word;     /* กันข้อความยาวล้น */
}










/* ===== SMS Modal Layout (balanced) ===== */
.smsModal{
  width: min(880px, calc(100vw - 28px));
  max-width: 880px;
  max-height: min(86vh, 720px);
  display:flex;
  flex-direction:column;
}

.smsBody{
  padding: 14px 16px 16px;
  overflow: auto;      /* ✅ modal ไม่ยาวทะลุจอ */
  min-height: 0;       /* ✅ สำคัญมาก ให้ลูกข้างในเลื่อนได้ */
}

.smsGrid{
  display:grid;
  grid-template-columns: 1.25fr .95fr; /* ซ้ายใหญ่ ขวารายงาน */
  gap: 14px;
  align-items: start;
}

.smsLeft textarea{
  resize: vertical;
}

.smsRight .smsReportCard{
  position: sticky;    /* ✅ รายงานอยู่ทรง ไม่ไหล */
  top: 0;
}

.smsRight .reportScroll{
  height: 320px;       /* ✅ คุมความสูงรายงาน */
  overflow-y: auto;
}

/* มือถือ: ให้เรียงลงล่าง */
@media (max-width: 860px){
  .smsGrid{ grid-template-columns: 1fr; }
  .smsRight .smsReportCard{ position: static; }
  .smsRight .reportScroll{ height: 240px; }
}


/* =========================
   Tournament Step 3 UI
   ========================= */
.divider{ height:1px; background: rgba(16,24,40,.10); }

.grid-2{
  display:grid;
  grid-template-columns: 1.25fr .95fr;
  gap: 14px;
}
@media(max-width: 980px){
  .grid-2{ grid-template-columns: 1fr; }
}

.inner-card{ padding:14px; border-radius:18px; }
.inner-title{ font-weight:900; }
.small{ font-size:12px; color: rgba(15,23,42,.72); }
.wheel-card-advanced{ padding:14px; border-radius:18px; }

.dual-wheel-wrap{
  margin-top:10px;
  display:grid;
  grid-template-columns: .78fr 1.22fr;
  gap: 12px;
  align-items:center;
}
@media(max-width: 860px){
  .dual-wheel-wrap{ grid-template-columns: 1fr; }
}

.wheel-column{ display:flex; flex-direction:column; gap:8px; align-items:center; }
.wheel-label-top{ font-weight:900; font-size:12px; color: rgba(15,23,42,.78); }

.spin-wheel{
  position:relative;
  border-radius: 999px;
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(16,185,129,.20);
  box-shadow: 0 18px 40px rgba(16,24,40,.12);
  overflow:hidden;
}
.small-wheel{ width: 210px; height:210px; }
.big-wheel{ width: 300px; height:300px; }

.wheel-svg{ width:100%; height:100%; display:block; }

.wheel-core{
  position:absolute;
  inset: 50% auto auto 50%;
  width: 18px; height: 18px;
  transform: translate(-50%,-50%);
  border-radius: 999px;
  background: rgba(15,23,42,.85);
  box-shadow: 0 6px 18px rgba(16,24,40,.25);
}
.wheel-center-text{
  position:absolute;
  left:50%; top:50%;
  transform: translate(-50%,-50%);
  font-weight: 1000;
  font-size: 12px;
  color: rgba(15,23,42,.85);
  background: rgba(255,255,255,.85);
  border: 1px solid rgba(16,185,129,.22);
  padding: 6px 10px;
  border-radius: 999px;
}

.wheel-status{ margin-top:8px; }
.current-draw-result{
  margin-top:6px;
  font-weight:900;
  color: rgba(15,23,42,.85);
}

.division-summary-block{
  padding: 12px;
  border-radius: 16px;
  background: rgba(16,185,129,.06);
  border: 1px solid rgba(16,185,129,.18);
  margin-bottom: 10px;
}
.division-summary-title{
  font-weight: 1000;
  color: var(--brand2);
  margin-bottom: 4px;
}
.group-title{
  margin-top:10px;
  font-weight:1000;
}
.group-team{
  font-weight: 700;
  margin-left: 10px;
  margin-top: 2px;
  color: rgba(15,23,42,.78);
}



