:root{
  --bg:#0b0e13;
  --panel:#121723;
  --panel2:#0f141f;
  --line:#222a3a;
  --text:#e9eefc;
  --muted:#9aa6c1;
  --gold:#f5c84c;
  --gold2:#d9a827;
  --danger:#ff4d4f;
  --ok:#2bd36b;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,PingFang SC,Microsoft YaHei,Arial;
  background: radial-gradient(900px 500px at 15% 10%, rgba(245,200,76,.18), transparent 60%),
              radial-gradient(900px 500px at 85% 20%, rgba(130,140,255,.10), transparent 60%),
              var(--bg);
  color:var(--text);
}
a{color:inherit;text-decoration:none}
.container{max-width:1200px;margin:0 auto;padding:22px 18px 60px}

.topbar{
  position:sticky;top:0;z-index:20;
  display:flex;align-items:center;gap:18px;
  padding:14px 18px;
  background: rgba(11,14,19,.75);
  backdrop-filter: blur(14px);
  border-bottom:1px solid rgba(34,42,58,.75);
}
.brand{display:flex;align-items:center;gap:12px;min-width:260px}
.brand img{width:46px;height:46px;border-radius:14px;border:1px solid rgba(245,200,76,.25);object-fit:cover}
.brandName{font-weight:900;font-size:16px;line-height:1.2}
.brandSub{font-size:12px;color:var(--muted)}
.nav{display:flex;gap:10px;flex-wrap:wrap}
.navLink{
  padding:10px 12px;border-radius:12px;
  border:1px solid transparent;
  color:var(--muted);
}
.navLink:hover{border-color:rgba(245,200,76,.25);color:var(--text)}
.navLink.active{
  background: linear-gradient(135deg, rgba(245,200,76,.18), rgba(245,200,76,.06));
  border-color:rgba(245,200,76,.35);
  color:var(--text);
}
.navLink.admin{
  border-color:rgba(130,140,255,.25);
  color:#cfd6ff;
}
.userBadge{margin-left:auto;display:flex;gap:10px;align-items:center}
.chip{
  padding:9px 12px;border-radius:999px;
  border:1px solid rgba(34,42,58,.9);
  background: rgba(18,23,35,.65);
  color:var(--muted);
}
.chip b{color:var(--text)}

.btn{
  cursor:pointer;
  padding:10px 14px;border-radius:12px;
  border:1px solid rgba(245,200,76,.35);
  background: linear-gradient(135deg, rgba(245,200,76,.22), rgba(245,200,76,.10));
  color:var(--text);
  font-weight:700;
}
.btn:hover{filter:brightness(1.06)}
.btn.ghost{
  border-color:rgba(34,42,58,.9);
  background: rgba(18,23,35,.65);
  color:var(--text);
}
.btn.danger{
  border-color:rgba(255,77,79,.45);
  background: rgba(255,77,79,.10);
}
.btn.ok{
  border-color:rgba(43,211,107,.45);
  background: rgba(43,211,107,.10);
}
.input, select, textarea{
  width:100%;
  padding:12px;
  border-radius:12px;
  border:1px solid rgba(34,42,58,.9);
  background:rgba(11,14,19,.35);
  color:var(--text);
  outline:none;
}
textarea{min-height:120px;resize:vertical}

.panel{
  border-radius:18px;
  background: rgba(18,23,35,.65);
  border:1px solid rgba(34,42,58,.85);
  overflow:hidden;
}
.panelTitle{
  padding:14px 16px;
  border-bottom:1px solid rgba(34,42,58,.85);
  font-weight:900;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.panelBody{padding:14px 16px}
.muted{color:var(--muted)}
.small{font-size:12px}
.mt12{margin-top:12px}
.mt16{margin-top:16px}
.mt24{margin-top:24px}
.grid2{display:grid;grid-template-columns:repeat(2,1fr);gap:12px}
.grid3{display:grid;grid-template-columns:repeat(3,1fr);gap:12px}
.grid4{display:grid;grid-template-columns:repeat(4,1fr);gap:14px}
.card{
  border-radius:18px;
  background: rgba(15,20,31,.70);
  border:1px solid rgba(34,42,58,.90);
  padding:14px;
}
.tag{
  display:inline-block;
  padding:6px 10px;border-radius:999px;
  border:1px solid rgba(245,200,76,.30);
  color:var(--gold);
  background: rgba(245,200,76,.08);
  font-weight:800;font-size:12px;
}
.hr{height:1px;background:rgba(34,42,58,.85);margin:14px 0}
.noticeBox{
  border-radius:14px;
  padding:14px;
  border:1px solid rgba(34,42,58,.9);
  background: rgba(11,14,19,.45);
  color:var(--text);
  line-height:1.6;
}
.row{display:flex;gap:10px;flex-wrap:wrap;align-items:center}
.row > *{flex:1;min-width:180px}

table{width:100%;border-collapse:collapse}
th,td{padding:10px;border-bottom:1px solid rgba(34,42,58,.75);font-size:13px}
th{color:var(--muted);text-align:left;font-weight:800}
td b{color:var(--text)}
.badge{
  padding:4px 8px;border-radius:999px;
  border:1px solid rgba(34,42,58,.9);
  background: rgba(18,23,35,.65);
  color:var(--muted);font-size:12px;font-weight:800;
}
.badge.ok{border-color:rgba(43,211,107,.45);color:rgba(43,211,107,.95)}
.badge.bad{border-color:rgba(255,77,79,.45);color:rgba(255,77,79,.95)}
.badge.warn{border-color:rgba(245,200,76,.45);color:rgba(245,200,76,.95)}

.toast{
  position:fixed;right:16px;bottom:16px;z-index:99;
  min-width:240px;max-width:420px;
  padding:12px 14px;border-radius:14px;
  border:1px solid rgba(34,42,58,.9);
  background: rgba(18,23,35,.92);
  box-shadow: 0 25px 80px rgba(0,0,0,.45);
  display:none;
}
.toast.show{display:block}
.toast .t{font-weight:900;margin-bottom:6px}
.toast .d{color:var(--muted);font-size:12px}

.modal{display:none;position:fixed;inset:0;z-index:50}
.modal.show{display:block}
.modalMask{position:absolute;inset:0;background:rgba(0,0,0,.55)}
.modalCard{
  position:relative;
  width:min(560px,92vw);
  margin:10vh auto 0;
  border-radius:18px;
  background: rgba(18,23,35,.92);
  border:1px solid rgba(245,200,76,.22);
  box-shadow: 0 25px 80px rgba(0,0,0,.55);
}
.modalHeader{
  padding:14px 16px;
  display:flex;align-items:center;justify-content:space-between;
  border-bottom:1px solid rgba(34,42,58,.85);
}
.modalTitle{font-weight:900}
.modalBody{padding:14px 16px;max-height:72vh;overflow:auto}
.modalFooter{padding:14px 16px;border-top:1px solid rgba(34,42,58,.85);display:flex;justify-content:flex-end;gap:10px}

@media (max-width: 1050px){
  .grid4{grid-template-columns:repeat(2,1fr)}
}
@media (max-width: 520px){
  .grid4{grid-template-columns:1fr}
  .nav{display:none}
  .brand{min-width:auto}
}

/* Mobile bottom navigation (for small screens) */
.mobileNav{display:none}
body.withMobileNav{padding-bottom:0}
@media (max-width: 520px){
  /* Bottom nav with iPhone safe-area support */
  .mobileNav{
    display:flex;
    position:fixed;
    left:0;right:0;bottom:0;
    height:calc(60px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    z-index:60;
    background: rgba(10,13,20,.92);
    border-top:1px solid rgba(34,42,58,.85);
    backdrop-filter: blur(10px);
  }
  body.withMobileNav{padding-bottom:calc(76px + env(safe-area-inset-bottom))}
  .mobileNav .mLink{
    flex:1;
    display:flex;
    align-items:center;
    justify-content:center;
    text-decoration:none;
    color:var(--muted);
    font-weight:900;
    letter-spacing:.5px;
    font-size:13px;
  }
  .mobileNav .mLink.active{
    color:var(--gold);
    background: linear-gradient(180deg, rgba(245,200,76,.12), rgba(245,200,76,0));
  }

  /* Make personal center/menu compact and responsive */
  .container{padding:16px 12px 90px}
  .panelTitle{padding:12px 14px}
  .panelBody{padding:12px 14px}

  .menu{
    flex-direction:row;
    gap:8px;
    overflow-x:auto;
    overflow-y:hidden;
    padding-bottom:6px;
    -webkit-overflow-scrolling: touch;
  }
  .menu::-webkit-scrollbar{display:none}
  .menuItem{
    flex:0 0 auto;
    padding:8px 10px;
    border-radius:12px;
    font-size:12px;
    line-height:1.1;
    white-space:nowrap;
  }

  /* Avoid right area being squeezed by min-width rules */
  .row > *{min-width:0; flex: 1 1 100%}

  /* Tables should not overflow the screen on iPhone */
  table{display:block; overflow-x:auto; width:100%}
  th,td{white-space:nowrap; padding:8px; font-size:12px}

  /* Stack grids on very small screens */
  .grid3{grid-template-columns:1fr}
}

/* New lottery UI helpers */
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:14px}
@media (max-width: 1050px){.grid2{grid-template-columns:1fr}}
.digits{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.digitBall{
  width:38px;height:38px;border-radius:999px;
  display:grid;place-items:center;
  border:1px solid rgba(245,200,76,.35);
  background: rgba(18,23,35,.65);
  font-weight:900;
}
.tab{
  cursor:pointer;
  padding:8px 12px;border-radius:12px;
  border:1px solid rgba(34,42,58,.9);
  background: rgba(18,23,35,.55);
  color:var(--text);
  font-weight:800;
}
.tab.active{
  border-color:rgba(245,200,76,.35);
  background: linear-gradient(135deg, rgba(245,200,76,.18), rgba(245,200,76,.06));
}

/* For modal tabs (avoid conflict with game play tabs) */
.subtab{
  cursor:pointer;
  padding:8px 12px;border-radius:12px;
  border:1px solid rgba(34,42,58,.9);
  background: rgba(18,23,35,.55);
  color:var(--text);
  font-weight:800;
}
.subtab.active{
  border-color:rgba(245,200,76,.35);
  background: linear-gradient(135deg, rgba(245,200,76,.18), rgba(245,200,76,.06));
}
.pickRow{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin:10px 0}
.pickLabel{width:64px;color:var(--muted);font-weight:800}
.pill{
  cursor:pointer;
  padding:8px 10px;border-radius:999px;
  border:1px solid rgba(34,42,58,.9);
  background: rgba(11,14,19,.35);
  color:var(--text);
  font-weight:800;
  min-width:36px;
  text-align:center;
}
.pill.active{
  border-color:rgba(245,200,76,.45);
  background: rgba(245,200,76,.12);
  color:var(--gold);
}
.pill.small{padding:6px 8px;font-size:12px;color:var(--muted)}
.miniList{display:flex;flex-direction:column;gap:8px}
.miniItem{
  padding:10px;border-radius:14px;
  border:1px solid rgba(34,42,58,.85);
  background: rgba(11,14,19,.25);
}

/* captcha */
.capWrap{gap:10px;align-items:center;flex-wrap:wrap}
.capQ{padding:10px 12px;border-radius:12px;border:1px solid rgba(34,42,58,.85);background:rgba(11,14,19,.25);color:var(--text);font-weight:800}

.menu{display:flex;flex-direction:column;gap:10px}
.menuItem{
  cursor:pointer;
  text-align:left;
  padding:12px 14px;
  border-radius:14px;
  border:1px solid rgba(34,42,58,.85);
  background: rgba(11,14,19,.25);
  color:var(--text);
  font-weight:800;
}
.menuItem.active{
  border-color:rgba(245,200,76,.35);
  background: linear-gradient(135deg, rgba(245,200,76,.18), rgba(245,200,76,.06));
}


/* ====== Lottery ball animation ====== */
.digitBall{
  position:relative;
  overflow:hidden;
  box-shadow: 0 10px 25px rgba(0,0,0,.35);
  transform: translateZ(0);
}
.digitBall::before{
  content:"";
  position:absolute; inset:-30%;
  background: radial-gradient(circle at 30% 25%, rgba(255,255,255,.65), rgba(255,255,255,0) 45%),
              radial-gradient(circle at 70% 80%, rgba(0,0,0,.25), rgba(0,0,0,0) 55%);
  transform: rotate(0deg);
  opacity:.55;
  pointer-events:none;
}

.digitBall::after{
  content:"";
  position:absolute;
  inset:-7px;
  border-radius:999px;
  pointer-events:none;
  opacity:.70;
  mix-blend-mode: screen;
  animation: glowPulse 1.25s ease-in-out infinite;
}
@keyframes glowPulse{
  0%{ opacity:.35; filter: blur(0px); }
  50%{ opacity:.85; filter: blur(0.2px); }
  100%{ opacity:.45; filter: blur(0px); }
}
/* position-based colors (each ball different) */
.pos0{background: linear-gradient(135deg, rgba(255,80,80,.95), rgba(160,0,0,.65)); border-color: rgba(255,120,120,.55);}
.pos1{background: linear-gradient(135deg, rgba(90,150,255,.95), rgba(0,60,160,.65)); border-color: rgba(120,180,255,.55);}
.pos2{background: linear-gradient(135deg, rgba(70,230,160,.95), rgba(0,120,80,.65)); border-color: rgba(120,255,200,.55);}
.pos3{background: linear-gradient(135deg, rgba(190,120,255,.95), rgba(90,0,160,.65)); border-color: rgba(220,170,255,.55);}
.pos4{background: linear-gradient(135deg, rgba(255,190,90,.95), rgba(160,90,0,.65)); border-color: rgba(255,220,150,.55);}
.pos0::after{box-shadow: 0 0 10px rgba(255,80,80,.55), 0 0 22px rgba(255,80,80,.35), 0 0 36px rgba(255,80,80,.18);} 
.pos1::after{box-shadow: 0 0 10px rgba(90,150,255,.55), 0 0 22px rgba(90,150,255,.35), 0 0 36px rgba(90,150,255,.18);} 
.pos2::after{box-shadow: 0 0 10px rgba(70,230,160,.55), 0 0 22px rgba(70,230,160,.35), 0 0 36px rgba(70,230,160,.18);} 
.pos3::after{box-shadow: 0 0 10px rgba(190,120,255,.55), 0 0 22px rgba(190,120,255,.35), 0 0 36px rgba(190,120,255,.18);} 
.pos4::after{box-shadow: 0 0 10px rgba(255,190,90,.55), 0 0 22px rgba(255,190,90,.35), 0 0 36px rgba(255,190,90,.18);} 


/* instant draw flash (no delay feeling) */
.digitBall.flash{
  animation: flashPop .22s ease-out 1;
}
@keyframes flashPop{
  0%{ transform: scale(1); filter: brightness(1); }
  50%{ transform: scale(1.06); filter: brightness(1.25); }
  100%{ transform: scale(1); filter: brightness(1); }
}

@keyframes ballSpin {
  0% { transform: translateZ(0) rotate(0deg) scale(1); filter: blur(0px); }
  50% { transform: translateZ(0) rotate(180deg) scale(1.06); filter: blur(.2px); }
  100% { transform: translateZ(0) rotate(360deg) scale(1); filter: blur(0px); }
}
@keyframes ballPop {
  0% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-6px) scale(1.08); }
  100% { transform: translateY(0) scale(1); }
}
.rolling{
  animation: ballSpin .55s linear infinite;
}
.rolling::before{
  animation: ballSpin .65s linear infinite;
  opacity:.75;
}
.reveal{
  animation: ballPop .35s ease-out 1;
}

/* ====== Dice UI ====== */
.diceDie{
  width:46px;height:46px;border-radius:14px;
  position:relative;
  display:block;
  border:1px solid rgba(255,255,255,.18);
  background: linear-gradient(145deg, rgba(220,35,35,.98), rgba(150,0,0,.85));
  box-shadow:
    0 12px 28px rgba(0,0,0,.45),
    inset 0 2px 10px rgba(255,255,255,.18),
    inset 0 -10px 18px rgba(0,0,0,.28);
  transform: translateZ(0);
}
.diceDie::before{
  content:"";
  position:absolute; inset:3px;
  border-radius:12px;
  background: radial-gradient(circle at 28% 24%, rgba(255,255,255,.35), rgba(255,255,255,0) 45%);
  pointer-events:none;
}
.pip{
  position:absolute;
  /* Smaller pips + percentage positioning to avoid pips touching after scaling */
  width:7px;height:7px;
  border-radius:999px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.35);
  transform: translate(-50%,-50%);
}
/* 3x3 grid positions: 1..9 */
.p1{left:24%;top:24%}
.p2{left:50%;top:24%}
.p3{left:76%;top:24%}
.p4{left:24%;top:50%}
.p5{left:50%;top:50%}
.p6{left:76%;top:50%}
.p7{left:24%;top:76%}
.p8{left:50%;top:76%}
.p9{left:76%;top:76%}
@keyframes diceShake {
  0%{ transform: translate(0,0) rotate(0deg); }
  20%{ transform: translate(-2px,1px) rotate(-6deg); }
  40%{ transform: translate(2px,-1px) rotate(6deg); }
  60%{ transform: translate(-2px,-1px) rotate(-4deg); }
  80%{ transform: translate(2px,1px) rotate(4deg); }
  100%{ transform: translate(0,0) rotate(0deg); }
}
.diceDie.shaking{
  animation: diceShake .25s linear infinite;
}

.diceSection{margin:10px 0;display:flex;gap:8px;flex-wrap:wrap;align-items:center}
.diceSectionTitle{width:100%;color:var(--muted);font-weight:900;margin-bottom:6px}



/* ===== Profile mobile upgrade (iPhone friendly) ===== */
.profileGrid{grid-template-columns:260px 1fr; gap:14px}

/* Mobile tabs only appear on small screens */
.mTabsWrap{display:none}
.mTabs{
  display:flex;
  gap:10px;
  overflow-x:auto;
  overflow-y:hidden;
  -webkit-overflow-scrolling: touch;
  padding:6px 2px 2px;
}
.mTabs::-webkit-scrollbar{display:none}
.mTab{
  cursor:pointer;
  flex:0 0 auto;
  padding:9px 12px;
  border-radius:999px;
  border:1px solid rgba(34,42,58,.90);
  background: rgba(18,23,35,.55);
  color:var(--muted);
  font-weight:900;
  font-size:13px;
  letter-spacing:.2px;
}
.mTab.active{
  color:var(--text);
  border-color:rgba(245,200,76,.45);
  background: linear-gradient(135deg, rgba(245,200,76,.20), rgba(245,200,76,.06));
}
.mTabsHint{margin-top:6px}

.fadeIn{animation:fadeIn .18s ease-out 1}
@keyframes fadeIn{
  from{opacity:.72; transform: translateY(2px)}
  to{opacity:1; transform: translateY(0)}
}

@media (max-width: 520px){
  /* Make profile page single column (avoid left/right squeeze) */
  .profileGrid{grid-template-columns:1fr !important}

  /* Hide desktop side menu, use mobile tabs */
  #sideMenuPanel{display:none}
  .mTabsWrap{display:block}

  /* Slightly more compact header for iPhone */
  .topbar{padding:12px 12px}
  .brand img{width:40px;height:40px;border-radius:12px}
  .chip{padding:8px 10px;font-size:12px}

  /* Make KPI cards readable */
  .heroMeta{grid-template-columns:repeat(2,1fr) !important}
}


/* --- fix badge wrapping in admin tables --- */
.badge{white-space:nowrap!important;display:inline-flex!important;align-items:center;justify-content:center;min-width:44px;}
/* --- end --- */


/* --- chat thread list scrolling --- */
#chatThreadList{
  max-height: 520px !important;
  overflow-y: auto !important;
  padding-right: 6px;
}
/* --- end --- */


/* --- chat thread list scrolling (always visible) --- */
#chatThreadList{
  max-height: calc(100vh - 260px) !important;
  overflow-y: scroll !important;
  padding-right: 6px;
}
#chatThreadList::-webkit-scrollbar{ width: 8px; }
#chatThreadList::-webkit-scrollbar-thumb{ background: rgba(255,255,255,.18); border-radius: 8px; }
#chatThreadList::-webkit-scrollbar-track{ background: rgba(255,255,255,.06); border-radius: 8px; }
/* --- end --- */
