/* Junkie Trade — GoDark-inspired single-column UI, pink theme */
:root{
  --bg:#0b0b10; --panel:#12121a; --panel2:#17171f; --line:rgba(255,255,255,.08);
  --up:#00ffa3; --down:#ff4d6d; --pink:#ff2d78; --pink-dim:rgba(255,45,120,.15);
  --amber:#ffd166; --blue:#38bdf8;
  --text:#f2f3f7; --muted:#8a93a6;
  --r:16px;
  --font-body:"Space Grotesk",system-ui,-apple-system,"Segoe UI",sans-serif;
  --font-mono:"JetBrains Mono",ui-monospace,monospace;
}
*{box-sizing:border-box; -webkit-tap-highlight-color:transparent;}
html,body{margin:0;padding:0;}
body{
  background:var(--bg); color:var(--text);
  font-family:var(--font-body);
  min-height:100vh; padding:14px 14px 40px; max-width:560px; margin:0 auto;
  user-select:none; -webkit-user-select:none;
}
.bg-orbs{position:fixed; inset:0; z-index:-1; overflow:hidden; pointer-events:none;}
.bg-orbs i{position:absolute; border-radius:50%; filter:blur(90px); opacity:.25;}
.bg-orbs i:nth-child(1){width:340px;height:340px;left:-120px;top:-80px;background:#4d0f2e;}
.bg-orbs i:nth-child(2){width:300px;height:300px;right:-100px;top:20%;background:#2a0f3d;}
.bg-orbs i:nth-child(3){width:260px;height:260px;left:10%;bottom:-120px;background:#0f2a4a;}
.hidden{display:none !important;}

/* ---------- header ---------- */
header{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:8px;margin:4px 2px 14px;max-width:100%;overflow:hidden;}
.brand{display:flex;align-items:center;gap:10px;flex-shrink:1;min-width:0;}
.brand .logo{height:38px;width:auto;display:block;filter:drop-shadow(0 2px 10px rgba(255,45,120,.35));flex-shrink:0;}
.brand b{font-size:17px;letter-spacing:2px;white-space:nowrap;}
.brand small{display:block;font-size:10px;letter-spacing:3px;color:var(--muted);font-weight:500;white-space:nowrap;}
.header-right{display:flex;align-items:center;gap:8px;flex-wrap:wrap;justify-content:flex-end;flex-shrink:1;min-width:0;max-width:100%;}
@media (max-width:480px){
  header{flex-wrap:wrap;row-gap:8px;overflow:hidden;}
  .brand{flex:1 1 auto;min-width:0;}
  .brand .logo{height:24px;}
  .brand b{font-size:11px;letter-spacing:1px;white-space:nowrap;}
  .brand small{display:none;}
  /* Actions take their own full-width row below the brand — nothing gets cut off */
  .header-right{flex:1 1 100%;gap:6px;flex-wrap:wrap;justify-content:flex-start;min-width:0;}
  .iconbtn{width:28px;height:28px;display:inline-flex;align-items:center;justify-content:center;padding:0;flex:0 0 auto;}
  .iconbtn svg{width:13px;height:13px;}
  .pill{padding:6px 10px;font-size:11px;flex:0 0 auto;}
  .btn-connect{padding:7px 12px;font-size:11px;flex:0 0 auto;margin-left:auto;}
}
.pill{background:rgba(255,255,255,.05);border:1px solid var(--line);border-radius:999px;
  padding:7px 12px;font-size:13px;font-weight:600;display:flex;align-items:center;gap:6px;white-space:nowrap;}
.pill.balance{color:var(--up); border-color:rgba(0,255,163,.25); background:rgba(0,255,163,.06);}
.pill.points{color:var(--amber); border-color:rgba(255,209,102,.25); background:rgba(255,209,102,.06);}
.iconbtn{background:rgba(255,255,255,.05);border:1px solid var(--line);border-radius:999px;
  padding:6px 9px;font-size:14px;line-height:1;color:var(--text);cursor:pointer;font-family:inherit;flex:0 0 auto;
  display:inline-flex;align-items:center;justify-content:center;}
.iconbtn svg{display:block;}
.iconbtn.off{opacity:.5;}

/* ---------- connect button ---------- */
.btn-connect{
  background:var(--pink); color:#fff; border:none; border-radius:999px;
  padding:8px 16px; font-size:13px; font-weight:700; cursor:pointer; font-family:inherit;
  box-shadow:0 0 16px rgba(255,45,120,.45); white-space:nowrap;
  max-width:150px; overflow:hidden; text-overflow:ellipsis;
}
.btn-connect.connected{background:rgba(255,255,255,.06); color:var(--up); border:1px solid rgba(0,255,163,.3); box-shadow:none;}

/* ---------- wallet popup (centered modal) ---------- */
.wallet-popup{min-width:min(320px,86vw); text-align:left;}
.wallet-popup-title{font-size:18px; font-weight:800; margin-bottom:12px; text-align:center;}
.wallet-menu-addr{
  font-family:var(--font-mono); font-size:13px; color:var(--text);
  background:rgba(255,255,255,.05); border-radius:8px; padding:8px 10px;
  cursor:pointer; text-align:center; margin-bottom:12px;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.wallet-menu-bal{display:flex; gap:8px; margin-bottom:12px;}
.wallet-menu-bal > div{flex:1; background:rgba(255,255,255,.03); border:1px solid var(--line); border-radius:10px; padding:10px; text-align:center;}
.wallet-menu-bal span{display:block; font-size:10px; color:var(--muted); letter-spacing:1px;}
.wallet-menu-bal b{font-size:18px; font-family:var(--font-mono);}
.wallet-menu-btn{width:100%; margin-bottom:8px;}
.wallet-menu-danger{color:#ff5252 !important; border-color:rgba(255,82,82,.3) !important;}
.wallet-popup .tx-status{margin:4px 0 8px; font-size:12px; min-height:0;}

/* ---------- VIP tiers popup (Stake-style) ---------- */
.vip-popup{min-width:min(340px,88vw); text-align:left; max-height:80vh; overflow-y:auto;}
.vip-popup-title{font-size:18px; font-weight:800; margin-bottom:4px; text-align:center;}
.vip-popup-sub{font-size:12px; color:var(--muted); text-align:center; margin-bottom:12px;}
.tier-row{display:flex; align-items:center; gap:10px; padding:10px 12px; border-radius:12px;
  border:1px solid var(--line); margin-bottom:8px; background:rgba(255,255,255,.02);}
.tier-row.current{border-color:var(--pink); background:var(--pink-dim);}
.tier-row.locked{opacity:.55;}
.tier-icon{font-size:24px;}
.tier-info{flex:1;}
.tier-name{font-weight:700; font-size:14px;}
.tier-req{font-size:11px; color:var(--muted); font-family:var(--font-mono);}
.tier-rb{font-size:12px; font-weight:700; color:var(--up); font-family:var(--font-mono); text-align:right;}
.tier-check{color:var(--up); font-weight:700;}

/* ---------- buttons ---------- */
.btn-pink{background:linear-gradient(135deg,#ff2d78,#ff5c9d); border:none; color:#fff; border-radius:10px;
  padding:10px 16px; font-size:13px; font-weight:700; cursor:pointer; font-family:inherit; width:100%;}
.btn-ghost{background:rgba(255,255,255,.05); border:1px solid var(--line); color:var(--text);
  border-radius:10px; padding:10px 16px; font-size:13px; font-weight:600; cursor:pointer; font-family:inherit;}
.btn-ghost:hover{border-color:var(--pink);}
.btn-pink:disabled,.btn-ghost:disabled{opacity:.4; cursor:not-allowed;}

/* ---------- cards ---------- */
.card{background:linear-gradient(180deg,var(--panel2),var(--panel));
  border:1px solid var(--line); border-radius:var(--r); padding:16px; margin-bottom:14px;
  box-shadow:0 8px 30px rgba(0,0,0,.35);}
.card h3{margin:0 0 10px; font-size:13px; letter-spacing:2px; color:var(--muted); font-weight:600;}
.card-text{font-size:13px; color:var(--muted); margin:0 0 10px;}
.empty{font-size:13px; color:var(--muted); margin:4px 0;}

/* ---------- market card ---------- */
.chart-head{display:flex; justify-content:space-between; align-items:flex-start; margin-bottom:2px;}
.asset{font-size:12px; letter-spacing:2px; color:var(--muted); font-weight:600; display:flex; align-items:center; gap:7px;}
.live-dot{width:8px; height:8px; border-radius:50%; background:var(--up); box-shadow:0 0 10px var(--up); animation:pulse 1.6s infinite;}
.feedbadge{font-size:9px; letter-spacing:1.5px; font-weight:700; padding:3px 8px; border-radius:99px;
  border:1px solid var(--line); color:var(--muted);}
.feedbadge.live{color:var(--up); border-color:rgba(0,255,163,.4);}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.35}}
.count-wrap{display:flex; flex-direction:column; align-items:center; gap:2px;}
.ringbox{position:relative; width:72px; height:72px;}
.ringbox svg{transform:rotate(-90deg);}
.ring-bg{fill:none; stroke:rgba(255,255,255,.08); stroke-width:6;}
.ring-fg{fill:none; stroke:var(--pink); stroke-width:6; stroke-linecap:round;
  stroke-dasharray:188.5; stroke-dashoffset:0; transition:stroke-dashoffset .5s linear;}
#countdown{position:absolute; inset:0; display:flex; align-items:center; justify-content:center;
  font-size:22px; font-weight:700; font-family:var(--font-mono);}
#countdown.urgent{color:var(--amber);}
#phase{font-size:10px; letter-spacing:1.5px; font-weight:700; color:var(--up);}
#phase.locked{color:var(--amber);} #phase.settle{color:var(--blue);}
.price-row{display:flex; align-items:baseline; gap:10px; margin-top:-56px;} /* pulled up beside the timer ring */
#bigPrice{font-size:34px; font-weight:700; font-family:var(--font-mono); letter-spacing:-1px; transition:color .15s;}
#bigPrice.tickup{color:var(--up);} #bigPrice.tickdn{color:var(--down);}
#priceChg{font-size:14px; font-weight:600; font-family:var(--font-mono);}
#priceChg.pos{color:var(--up);} #priceChg.neg{color:var(--down);}
.trade-sub{font-size:12px; color:var(--muted); margin:2px 0 0;}
.chart-wrap{height:220px; margin-bottom:12px;}
#priceChart{width:100%; height:100%; display:block;}

/* ---------- stake ---------- */
.stake-row{display:flex; gap:8px; flex-wrap:wrap; margin-bottom:8px; align-items:center;}
.chip{background:rgba(255,255,255,.05); border:1px solid var(--line); color:var(--text);
  border-radius:10px; padding:9px 0; font-size:14px; font-weight:700; cursor:pointer; font-family:inherit;
  flex:1; min-width:52px; touch-action:manipulation;}
.chip.sel{border-color:var(--pink); background:var(--pink-dim); box-shadow:0 0 12px rgba(255,45,120,.25);}
.chip-max{border-color:rgba(255,209,102,.4); color:var(--amber);}
#amountInput{flex:1.4; min-width:80px; background:rgba(255,255,255,.05); border:1px solid var(--line);
  border-radius:10px; padding:9px 10px; color:var(--text); font-size:14px; font-weight:700; font-family:var(--font-mono);}
#amountInput::placeholder{color:var(--muted); font-weight:400;}
.balance-line{font-size:12px; color:var(--muted); margin-bottom:12px;}

/* ---------- bet buttons ---------- */
.btn-row{display:flex; gap:10px;}
.betbtn{flex:1; border:none; border-radius:14px; padding:16px 8px; font-size:19px; font-weight:700; letter-spacing:1px;
  cursor:pointer; font-family:inherit; color:#fff; touch-action:manipulation;
  transition:transform .08s, filter .2s, opacity .2s; position:relative; overflow:hidden;
  display:flex; flex-direction:column; align-items:center; gap:2px;}
.betbtn small{display:block; font-size:11px; font-weight:600; letter-spacing:.5px; margin-top:3px; opacity:.85; font-family:var(--font-mono);}
.betbtn:active{transform:scale(.96);}
#sideUp{background:linear-gradient(135deg,#00ffa3,#00c878); box-shadow:0 6px 24px rgba(0,255,163,.35); text-shadow:0 1px 4px rgba(0,0,0,.3);}
#sideDown{background:linear-gradient(135deg,#ff4d6d,#e0264a); box-shadow:0 6px 24px rgba(255,77,109,.35); text-shadow:0 1px 4px rgba(0,0,0,.3);}
.betbtn[aria-pressed="true"]{outline:2px solid #fff; outline-offset:2px;}
.betbtn:disabled{filter:grayscale(.7) brightness(.6); cursor:not-allowed; box-shadow:none;}
.betbtn.shake{animation:deny .3s;}
@keyframes deny{0%,100%{transform:translateX(0)}25%{transform:translateX(-6px)}75%{transform:translateX(6px)}}
.bet-meta{display:flex; justify-content:space-between; align-items:center; margin-top:10px; gap:8px;}
.payout-line{font-size:13px; color:var(--muted);}
.payout-line b{color:var(--up); font-family:var(--font-mono);}
.payout-line span{font-family:var(--font-mono);}
#rebetBtn{background:rgba(255,255,255,.05); border:1px solid var(--line); color:var(--text);
  border-radius:10px; padding:8px 14px; font-size:12px; font-weight:600; cursor:pointer; font-family:inherit;}
.btn-buy{
  width:100%; margin-top:12px; border:none; border-radius:14px; padding:16px;
  font-size:16px; font-weight:700; letter-spacing:1px; cursor:pointer; font-family:inherit;
  background:linear-gradient(135deg,#ff2d78,#ff5c9d); color:#fff;
  box-shadow:0 6px 24px rgba(255,45,120,.35);
}
.btn-buy:disabled{filter:grayscale(.6) brightness(.7); cursor:not-allowed; box-shadow:none;}
.fineprint{font-size:11px; color:var(--muted); text-align:center; margin:10px 0 0;}
.tx-status{font-size:13px; margin:8px 0 0; min-height:18px; text-align:center; word-break:break-all;}
.tx-status.ok{color:var(--up);} .tx-status.err{color:var(--down);} .tx-status.busy{color:var(--amber);}
.tx-status a{color:var(--blue);}

/* ---------- history cards ---------- */
.round-history{display:flex; gap:8px; overflow-x:auto; padding-bottom:4px; scrollbar-width:thin;}
.round-history::-webkit-scrollbar{height:4px;}
.round-history::-webkit-scrollbar-thumb{background:var(--pink); border-radius:4px;}
.hcard{flex:0 0 auto; width:128px; border-radius:12px; border:1px solid var(--line); background:rgba(255,255,255,.03);
  padding:10px; cursor:pointer; font-family:inherit; color:var(--text); text-align:left;}
.hcard .hdir{font-size:17px; font-weight:800;}
.hcard.mup{border-color:rgba(0,255,163,.4);} .hcard.mup .hdir{color:var(--up);}
.hcard.mdn{border-color:rgba(255,77,109,.4);} .hcard.mdn .hdir{color:var(--down);}
.hcard .hnum{font-size:10px; color:var(--muted); font-family:var(--font-mono); margin:4px 0 2px;}
.hchart{width:100%; height:40px; display:block; margin:6px 0 4px; border-radius:6px; background:rgba(0,0,0,.25);}
.hcard .hprices{font-size:10px; font-family:var(--font-mono); color:var(--muted); line-height:1.5;}
.hcard .hmove{font-size:11px; font-family:var(--font-mono); font-weight:700; margin-top:2px;}
.hcard.mup .hmove{color:var(--up);} .hcard.mdn .hmove{color:var(--down);}
.hcard-live{flex:0 0 auto; width:64px; border-radius:12px; border:1px dashed var(--pink);
  display:flex; align-items:center; justify-content:center; flex-direction:column;
  color:var(--pink); font-size:11px; font-weight:700; gap:4px;}
.hcard-live .pulse-dot{width:10px; height:10px; border-radius:50%; background:var(--pink); animation:pulse 1s infinite;}
.trend-readout{font-size:11px; color:var(--muted); text-align:center; margin-top:8px;}

/* ---------- stats ---------- */
.sgrid{display:grid; grid-template-columns:1fr 1fr; gap:8px; margin-bottom:10px;}
.stat{background:rgba(255,255,255,.03); border:1px solid var(--line); border-radius:12px; padding:10px 12px;}
.stat .k{font-size:10px; letter-spacing:1.5px; color:var(--muted); font-weight:600;}
.stat .v{font-size:19px; font-weight:700; font-family:var(--font-mono); margin-top:3px;}
.vip-row{text-align:center;}
#vipChip{display:inline-block; font-size:12px; font-weight:700; padding:6px 14px; border-radius:99px;
  border:1px solid var(--line); color:var(--muted); cursor:pointer;}

/* ---------- positions & trades ---------- */
.pos-row,.hist-row{display:flex; justify-content:space-between; align-items:center;
  padding:10px 4px; border-bottom:1px solid var(--line); font-size:13px;}
.pos-row:last-child,.hist-row:last-child{border-bottom:none;}
.pos-side-up{color:var(--up); font-weight:700;} .pos-side-down{color:var(--down); font-weight:700;}
.pos-pnl{font-family:var(--font-mono); font-weight:700;}
.pos-pnl.w{color:var(--up);} .pos-pnl.l{color:var(--down);}
.hist-row .hside{font-weight:700;} .hist-row .hside.up{color:var(--up);} .hist-row .hside.down{color:var(--down);}
.hist-row .hamt{font-family:var(--font-mono); color:var(--muted);}

/* ---------- positions & trades (JS-generated) ---------- */
.pos{background:rgba(255,255,255,.03); border:1px solid var(--line); border-radius:12px; padding:12px; margin-bottom:8px;}
.pos-head{display:flex; justify-content:space-between; align-items:center; margin-bottom:6px;}
.pos-market{font-weight:700; font-family:var(--font-mono); font-size:13px;}
.pos-status{font-size:11px; font-weight:700; letter-spacing:1px; text-transform:uppercase; padding:3px 10px; border-radius:99px; border:1px solid var(--line); color:var(--muted);}
.pos-status.open{color:var(--blue); border-color:rgba(56,189,248,.4);}
.pos-status.won{color:var(--up); border-color:rgba(0,255,163,.4);}
.pos-status.lost{color:var(--down); border-color:rgba(255,77,109,.4);}
.pos-status.claimed{color:var(--muted);}
.pos-rows{font-size:12px; color:#b9c2d4; line-height:1.7; font-family:var(--font-mono);}
.pos-rows strong{color:var(--up);}
.pos-actions{margin-top:8px; display:flex; gap:8px;}
.btn-small{padding:8px 14px; font-size:12px; border-radius:8px; font-weight:700; cursor:pointer; font-family:inherit; border:1px solid var(--line);}
.btn-sell{background:rgba(255,209,102,.12); border-color:rgba(255,209,102,.4); color:var(--amber);}
.btn-redeem{background:rgba(0,255,163,.12); border-color:rgba(0,255,163,.4); color:var(--up);}
.pos-side-up{color:var(--up); font-weight:700;} .pos-side-down{color:var(--down); font-weight:700;}
.sell-form{margin-top:8px; display:flex; gap:8px; align-items:center;}
.sell-form input{flex:1; background:rgba(255,255,255,.05); border:1px solid var(--line); border-radius:8px;
  padding:8px 10px; color:var(--text); font-family:var(--font-mono); font-size:13px;}

/* ---------- how it works ---------- */
details.how{background:linear-gradient(180deg,var(--panel2),var(--panel));
  border:1px solid var(--line); border-radius:var(--r); padding:16px; margin-bottom:14px;}
details.how summary{cursor:pointer; font-size:13px; letter-spacing:2px; color:var(--muted); font-weight:600; list-style:none;}
details.how summary::-webkit-details-marker{display:none;}
details.how ul{padding-left:18px; margin:8px 0;}
details.how li{font-size:13px; color:#b9c2d4; line-height:1.65; margin-bottom:4px;}
details.how .risk{font-size:12px; color:var(--amber); line-height:1.5;}

footer{text-align:center; font-size:12px; color:var(--muted); line-height:1.7; padding:8px 0 20px;}
footer b{letter-spacing:1px;}
footer a{color:var(--pink); text-decoration:none;}

/* ---------- toasts ---------- */
#toastRegion{position:fixed; top:14px; left:50%; transform:translateX(-50%); z-index:100;
  display:flex; flex-direction:column; gap:8px; align-items:center; width:min(92vw,420px); pointer-events:none;}
.toast{background:#101828; border:1px solid var(--line); border-radius:12px; padding:10px 16px;
  font-size:13px; font-weight:600; box-shadow:0 8px 24px rgba(0,0,0,.5);}
.toast.ok{border-color:rgba(0,255,163,.4); color:var(--up);}
.toast.err{border-color:rgba(255,77,109,.4); color:var(--down);}

/* ---------- overlays / modals ---------- */
.win-overlay{position:fixed; inset:0; z-index:90; background:rgba(0,0,0,.7);
  display:none; align-items:center; justify-content:center; padding:20px;}
.win-overlay.show{display:flex;}
.win-content{background:var(--panel2); border:1px solid var(--pink); border-radius:16px;
  padding:28px; text-align:center; max-width:320px; animation:pop .3s;}
@keyframes pop{from{transform:scale(.85); opacity:0}to{transform:scale(1); opacity:1}}
.win-label{font-size:14px; letter-spacing:2px; color:var(--muted); font-weight:700;}
.win-amount{font-size:42px; font-weight:800; font-family:var(--font-mono); color:var(--up); margin:8px 0;}
