:root{
  --bg:#0f1016; --card:#1a1c25; --card2:#222530; --line:#2c2f3a;
  --text:#e8e9ee; --muted:#9a9db0; --accent:#8b7bff; --accent2:#5865F2;
  --ok:#3ba55d; --err:#ed4245; --radius:14px;
}
*{box-sizing:border-box}
body{
  margin:0; min-height:100vh; background:radial-gradient(1200px 600px at 50% -10%,#1b1d2b,#0f1016 60%);
  color:var(--text); font-family:"Segoe UI",system-ui,-apple-system,"Noto Sans Thai",sans-serif;
  display:flex; align-items:center; justify-content:center; padding:24px;
}
.wrap{width:100%; max-width:440px}
.card{
  background:var(--card); border:1px solid var(--line); border-radius:var(--radius);
  padding:30px 28px 28px; box-shadow:0 20px 60px rgba(0,0,0,.45);
}
.brand{font-size:26px; font-weight:700; letter-spacing:.3px; margin-bottom:18px}
.brand .logo{color:var(--accent); margin-right:4px}
.brand .hub{color:var(--accent)}
.lead{font-size:16px; margin:0 0 18px; line-height:1.55}
.muted{color:var(--muted)}
.small{font-size:12.5px}
.btn{
  display:flex; align-items:center; justify-content:center; gap:9px;
  width:100%; padding:13px 16px; margin:9px 0; border:none; border-radius:11px;
  font-size:15px; font-weight:600; cursor:pointer; text-decoration:none; color:#fff;
  transition:filter .15s, transform .05s;
}
.btn:active{transform:translateY(1px)}
.btn:hover{filter:brightness(1.08)}
.btn-discord{background:var(--accent2)}
.btn-primary{background:linear-gradient(90deg,#8b7bff,#6e5cff)}
.btn-ghost{background:var(--card2); color:var(--text); border:1px solid var(--line)}
.di{font-size:17px}
.form{margin-top:6px}
.field{display:block; margin:0 0 15px}
.flabel{display:block; font-size:13.5px; color:var(--muted); margin-bottom:7px}
.field input{
  width:100%; padding:12px 14px; background:var(--bg); color:var(--text);
  border:1px solid var(--line); border-radius:10px; font-size:15px; outline:none;
}
.field input:focus{border-color:var(--accent)}
.err{background:rgba(237,66,69,.12); border:1px solid rgba(237,66,69,.4); color:#ffb3b5;
  padding:11px 13px; border-radius:10px; font-size:14px; margin:4px 0 14px}
.section-label{font-size:12.5px; font-weight:600; color:var(--muted); text-transform:uppercase;
  letter-spacing:.6px; margin:4px 0 9px}
.profile{display:flex; align-items:center; gap:14px; margin-bottom:18px}
.avatar{width:62px; height:62px; border-radius:50%; border:2px solid var(--line); background:var(--card2)}
.pname{font-size:19px; font-weight:700}
.kv{margin:0 0 18px; display:grid; gap:1px; background:var(--line); border:1px solid var(--line); border-radius:11px; overflow:hidden}
.kv>div{display:flex; justify-content:space-between; gap:12px; background:var(--card); padding:12px 14px}
.kv dt{color:var(--muted); font-size:13.5px; margin:0}
.kv dd{margin:0; font-weight:600}
.row{display:flex; gap:10px}
.row .btn{margin:0}
.foot{text-align:center; color:var(--muted); font-size:12px; margin-top:16px}
.devbadge{display:inline-block; vertical-align:middle; margin-left:8px; padding:2px 8px;
  font-size:11px; font-weight:700; letter-spacing:.5px; color:#ffcf5a;
  background:rgba(255,193,69,.12); border:1px solid rgba(255,193,69,.45); border-radius:7px}
.devreset{display:block; text-align:center; margin-top:14px; font-size:12.5px; color:var(--muted);
  text-decoration:none}
.devreset:hover{color:var(--accent)}
body.is-dev .card{border-top:2px solid rgba(255,193,69,.5)}

/* ───────────── app shell (dashboard) ───────────── */
body.app{display:block; align-items:stretch; justify-content:flex-start; padding:0; background:var(--bg)}
.shell{display:flex; min-height:100vh}
.ic{width:18px; height:18px; flex:0 0 18px; fill:none; stroke:currentColor; stroke-width:1.7;
  stroke-linecap:round; stroke-linejoin:round}

/* sidebar */
.sidebar{width:248px; flex:0 0 248px; background:#15161e; border-right:1px solid var(--line);
  display:flex; flex-direction:column; position:sticky; top:0; height:100vh}
.side-top{padding:18px 18px 12px}
.side-top .brand{font-size:21px; margin:0}
.nav{flex:1; overflow-y:auto; padding:10px 12px; display:flex; flex-direction:column; gap:2px}
.nav-item{display:flex; align-items:center; gap:11px; padding:9px 11px; border-radius:9px;
  color:var(--muted); text-decoration:none; font-size:14.5px; font-weight:500}
.nav-item span{flex:1}
.nav-item:hover{background:#20222c; color:var(--text)}
.nav-item.active{background:rgba(139,123,255,.15); color:#cbc2ff}
.nav-item.active .ic{color:var(--accent)}
.soon{flex:none!important; font-size:10px; color:var(--muted); background:#20222c;
  padding:2px 6px; border-radius:6px; font-weight:600}
.nav-group{margin-top:2px}
.nav-group-head{display:flex; align-items:center; gap:11px; width:100%; padding:9px 11px;
  border:none; background:none; color:var(--muted); font-size:14.5px; font-weight:500;
  cursor:pointer; border-radius:9px; font-family:inherit}
.nav-group-head span{flex:1; text-align:left}
.nav-group-head:hover{background:#20222c; color:var(--text)}
.nav-group-head .chev{width:16px; height:16px; flex:0 0 16px; transition:transform .15s}
.nav-group.collapsed .nav-group-head .chev{transform:rotate(-90deg)}
.nav-group.collapsed .nav-group-body{display:none}
.nav-group-body{display:flex; flex-direction:column; gap:1px; margin-top:1px}
.nav-sub{display:block; padding:7px 11px 7px 41px; border-radius:8px; color:var(--muted);
  text-decoration:none; font-size:13.5px}
.nav-sub:hover{background:#20222c; color:var(--text)}

/* user panel (bottom-left) + dropdown */
.side-bottom{padding:10px; border-top:1px solid var(--line); position:relative}
.userbtn{display:flex; align-items:center; gap:10px; width:100%; padding:8px 9px; background:none;
  border:1px solid transparent; border-radius:10px; cursor:pointer; color:var(--text); font-family:inherit}
.userbtn:hover{background:#20222c; border-color:var(--line)}
.u-avatar{width:34px; height:34px; border-radius:50%; background:var(--card2); flex:0 0 34px}
.u-meta{display:flex; flex-direction:column; align-items:flex-start; min-width:0; flex:1; overflow:hidden}
.u-name{font-size:14px; font-weight:600; max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.u-sub{font-size:12px; color:var(--muted); max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.userbtn .chev{color:var(--muted); width:16px; height:16px; flex:0 0 16px}
.usermenu{position:absolute; left:10px; right:10px; bottom:68px; background:#20222c;
  border:1px solid var(--line); border-radius:11px; padding:6px;
  box-shadow:0 14px 34px rgba(0,0,0,.55); display:none; flex-direction:column; gap:2px}
.usermenu.open{display:flex}
.um-item{display:flex; align-items:center; gap:10px; padding:9px 10px; border-radius:8px;
  color:var(--text); text-decoration:none; font-size:14px}
.um-item span{flex:1}
.um-item:hover{background:#2a2d39}
/* ไกด์ลูกศรเด้งชี้ลงที่โปรไฟล์ (เบสท์ 1116) — ซ่อนตอนเมนูเปิด */
.um-hint{display:block; width:100%; margin:0 0 8px; padding:8px 10px 6px; border:1px dashed rgba(139,123,255,.55);
  border-radius:10px; background:rgba(139,123,255,.09); color:#c9c1ff; font:inherit; font-size:12.5px;
  line-height:1.45; text-align:center; cursor:pointer}
.um-hint:hover{background:rgba(139,123,255,.16)}
.um-arrow{display:block; font-size:20px; line-height:1; margin-top:3px; color:var(--accent);
  animation:um-bounce 1.1s ease-in-out infinite}
@keyframes um-bounce{0%,100%{transform:translateY(-2px)} 50%{transform:translateY(5px)}}
@media (prefers-reduced-motion:reduce){.um-arrow{animation:none}}
.usermenu.open ~ .um-hint{display:none}
.um-dev{color:#ffcf5a; margin-top:2px; border-top:1px solid var(--line); border-radius:0 0 8px 8px}

/* main */
.main{flex:1; min-width:0; display:flex; flex-direction:column}
.topbar{display:flex; align-items:center; gap:12px; padding:15px 24px; border-bottom:1px solid var(--line);
  position:sticky; top:0; background:rgba(15,16,22,.86); backdrop-filter:blur(7px); z-index:5}
.page-title{font-size:18px; font-weight:600; margin:0}
.menu-toggle{display:none; background:none; border:1px solid var(--line); border-radius:8px;
  padding:7px; color:var(--text); cursor:pointer}
.content{padding:26px 24px; max-width:1060px; width:100%}
.welcome{font-size:21px; font-weight:600; margin:0 0 3px}
.welcome-sub{color:var(--muted); margin:0 0 22px; font-size:14.5px}

/* KPI cards */
.kpi-row{display:grid; grid-template-columns:repeat(auto-fit,minmax(190px,1fr)); gap:14px; margin-bottom:22px}
.kpi{background:var(--card); border:1px solid var(--line); border-radius:12px; padding:16px 17px}
.k-label{display:flex; align-items:center; gap:8px; font-size:13px; color:var(--muted)}
.k-label span{font-weight:500}
.k-label .ic{width:16px; height:16px; flex:0 0 16px}
.k-soon{margin-left:auto; font-size:10.5px; color:#ffcf5a; background:rgba(255,193,69,.1);
  border:1px solid rgba(255,193,69,.3); padding:1px 7px; border-radius:6px}
.k-val{font-size:27px; font-weight:700; margin-top:10px}

/* panel */
.panel{background:var(--card); border:1px solid var(--line); border-radius:12px; padding:18px 18px 8px}
.panel h2{font-size:15px; font-weight:600; margin:0 0 13px}

/* sidebar accent in dev */
body.app.is-dev .sidebar{box-shadow:inset 0 2px 0 rgba(255,193,69,.5)}

/* responsive */
.sb-overlay{display:none}
@media (max-width:860px){
  .sidebar{position:fixed; left:0; top:0; z-index:40; transform:translateX(-100%); transition:transform .22s ease}
  .sidebar.open{transform:none}
  .menu-toggle{display:inline-flex}
  .sb-overlay{position:fixed; inset:0; background:rgba(0,0,0,.5); z-index:30}
  .sb-overlay.show{display:block}
  .content{padding:20px 16px}
}

/* ── การ์ดโปรไฟล์ / หน้าสมาชิก (1112) ── */
.cards{display:grid; grid-template-columns:repeat(auto-fill,minmax(260px,1fr)); gap:14px; margin:14px 0 22px}
.cards.one{grid-template-columns:minmax(260px,420px)}
.pcard{background:var(--card); border:1px solid var(--line); border-radius:12px; padding:16px}
.pcard.self{border-color:rgba(139,123,255,.55)}
.pc-head{display:flex; align-items:center; gap:12px; margin-bottom:14px}
.pc-avatar{width:46px; height:46px; border-radius:50%; background:var(--card2); flex:0 0 46px}
.pc-id{min-width:0}
.pc-name{font-size:16px; font-weight:700; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.pc-nick{font-size:13px; color:var(--muted)}
.pc-stats{display:grid; grid-template-columns:1fr 1fr; grid-template-rows:auto auto; column-gap:10px; margin:0}
/* subgrid: แถวหัวช่องสูงเท่ากันทั้งสองกล่อง → ตัวเลขยอดเติมกับ rebate อยู่ระดับเดียวกันแม้หัว "ยอดเติม 26/10 ถึง 25/11 (ก่อนตัดรอบ)" ขึ้นสองบรรทัด */
.pc-stats>div{background:var(--card2); border-radius:9px; padding:10px 11px; display:grid; grid-row:span 2; grid-template-rows:subgrid; row-gap:0}
.pc-stats .nw{white-space:nowrap}
.pc-stats dt{font-size:12px; color:var(--muted); margin:0 0 4px}
.pc-stats dd{margin:0; display:flex; flex-direction:column; gap:2px}
.pc-stats b{font-size:17px}
.pc-sub{font-size:11.5px; color:var(--muted)}
.pc-tag{font-size:10.5px; color:#ffcf5a; align-self:flex-start; background:rgba(255,193,69,.1); border:1px solid rgba(255,193,69,.35); border-radius:6px; padding:0 6px}
.pc-note{font-size:12.5px; color:var(--muted)}
.pc-games{margin-top:11px; font-size:13px}
.pc-games summary{cursor:pointer; color:var(--muted)}
.pc-games ul{list-style:none; margin:8px 0 0; padding:0; max-height:220px; overflow-y:auto}
.pc-games li{display:flex; justify-content:space-between; gap:10px; padding:4px 2px; border-bottom:1px solid var(--line)}
.search{width:100%; max-width:420px; padding:10px 13px; background:var(--bg); color:var(--text); border:1px solid var(--line); border-radius:10px; font-size:14px; outline:none}
.search:focus{border-color:var(--accent)}
.bank{display:flex; align-items:center; gap:7px; font-weight:500!important; text-align:right}
.ok-dot,.warn-dot{width:8px; height:8px; border-radius:50%; flex:0 0 8px; background:var(--ok)}
.warn-dot{background:#ffb545}
.check{display:flex; gap:9px; align-items:flex-start; font-size:13.5px; color:var(--muted); margin:2px 0 16px; line-height:1.5}
.check input{margin-top:3px}
.nick-preview{margin:-6px 0 14px}
.nick-preview .over{color:#ffb3b5}
.tbl{width:100%; border-collapse:collapse; font-size:13px; margin:14px 0}
.tbl th,.tbl td{text-align:left; padding:7px 8px; border-bottom:1px solid var(--line)}
.tbl th{color:var(--muted); font-weight:500}

/* แจ้งเปลี่ยนไอดีเกม (หน้าแก้ชื่อ) — เบสท์ 1116 */
.idreq{margin-top:22px; padding-top:18px; border-top:1px solid var(--line)}
.idreq h2{font-size:15px; font-weight:600; margin:0 0 4px}
.ok{background:rgba(59,165,93,.12); border:1px solid rgba(59,165,93,.4); color:#a8e6bd;
  padding:10px 12px; border-radius:10px; font-size:14px; margin:10px 0}
.idreq-list{list-style:none; padding:0; margin:14px 0 0; font-size:13px}
.idreq-list li{display:flex; justify-content:space-between; gap:10px; padding:7px 0; border-bottom:1px solid var(--line)}
.idreq-wait{color:#ffcf5a; white-space:nowrap}
.idreq-done{color:var(--muted); white-space:nowrap}

/* เกม Event: หมุนวงล้อ / วิ่งเป็ด — เบสท์ 1116 */
.nav-sub.active{background:rgba(139,123,255,.15); color:#cbc2ff}
.game{display:grid; grid-template-columns:300px 1fr; gap:18px; align-items:start}
.game-side h2{display:flex; justify-content:space-between; align-items:baseline}
.game-names{width:100%; box-sizing:border-box; resize:vertical; min-height:220px; background:#0f1016; color:var(--text);
  border:1px solid var(--line); border-radius:10px; padding:10px; font:inherit; font-size:14px; line-height:1.5}
.game-tools{display:flex; flex-direction:column; gap:6px; margin:10px 0}
.game-tools .btn{width:100%}
.game-main{min-width:0}
.game-actions{display:flex; flex-wrap:wrap; align-items:center; gap:14px; margin-top:14px; justify-content:center}
.btn-big{font-size:18px; padding:12px 34px; width:auto}
.btn:disabled{opacity:.45; cursor:not-allowed; filter:none}
.game-dur select{background:#0f1016; color:var(--text); border:1px solid var(--line); border-radius:8px; padding:6px 8px; font:inherit; margin-left:6px}
.wheel-wrap{position:relative; max-width:560px; margin:0 auto}
.wheel-wrap canvas{display:block; width:100%; height:auto; cursor:pointer; filter:drop-shadow(0 12px 30px rgba(0,0,0,.45))}
.wheel-pointer{position:absolute; top:-6px; left:50%; transform:translateX(-50%); z-index:2; width:0; height:0;
  border-left:18px solid transparent; border-right:18px solid transparent; border-top:34px solid #f0b232;
  filter:drop-shadow(0 3px 4px rgba(0,0,0,.5))}
.duck-wrap{width:100%; border-radius:12px; overflow:hidden; border:1px solid var(--line)}
.duck-wrap canvas{display:block; width:100%}
.win-modal{position:fixed; inset:0; z-index:50; display:flex; align-items:center; justify-content:center;
  background:rgba(8,9,14,.72); backdrop-filter:blur(3px); padding:16px}
.win-modal[hidden]{display:none}
.win-card{background:var(--card); border:1px solid var(--accent); border-radius:16px; padding:26px 28px; text-align:center;
  min-width:260px; max-width:420px; box-shadow:0 20px 60px rgba(0,0,0,.6); animation:win-pop .35s ease-out}
.win-name{font-size:30px; font-weight:700; margin:6px 0 18px; color:#fff; word-break:break-word}
.win-rank{text-align:left; margin:0 0 18px; padding-left:18px; font-size:14px; color:var(--muted); max-height:240px; overflow:auto}
@keyframes win-pop{from{transform:scale(.85); opacity:0} to{transform:scale(1); opacity:1}}
@media (max-width:860px){ .game{grid-template-columns:1fr} .game-main{order:-1} .game-names{min-height:120px} }

/* item code (เบสท์ 1116) */
.nav-item .nav-badge{flex:none; min-width:20px; height:20px; padding:0 6px; border-radius:10px; background:var(--err); color:#fff;
  font-size:11.5px; font-weight:700; display:inline-flex; align-items:center; justify-content:center; box-sizing:border-box}
.codes{display:grid; grid-template-columns:repeat(auto-fill,minmax(300px,1fr)); gap:14px}
.code-card{background:var(--card); border:1px solid var(--accent); border-radius:12px; padding:14px 16px}
.code-card.done{border-color:var(--line); opacity:.7}
.code-title{display:flex; justify-content:space-between; gap:10px; font-weight:600; font-size:14px; margin-bottom:10px}
.code-row{display:flex; gap:8px; align-items:center}
.code-val{flex:1; min-width:0; font-family:ui-monospace,Consolas,monospace; font-size:15px; letter-spacing:.5px;
  background:#0f1016; border:1px dashed var(--line); border-radius:8px; padding:10px 12px; overflow-wrap:anywhere; user-select:all}
.code-copy{width:auto; margin:0; padding:10px 14px; flex:0 0 auto}
.code-card form .btn{margin:10px 0 0}
.bad{color:#ffb3b5}

/* กระเป๋าเหรียญ (เบสท์ 1116) */
.coin-hero{margin-bottom:16px}
.coin-balance{font-size:40px; font-weight:700; color:#ffd36b; margin:4px 0 6px}
.coin-unit{font-size:16px; font-weight:600; color:var(--muted)}
.coin-grid{display:grid; grid-template-columns:1fr 1fr; gap:16px; margin-bottom:12px}
.coin-plus{color:#7be0a0; font-weight:600; white-space:nowrap}
.coin-minus{color:#ffb3b5; font-weight:600; white-space:nowrap}
.tbl tr.me td{background:rgba(139,123,255,.12)}
@media (max-width:860px){ .coin-grid{grid-template-columns:1fr} }
