:root {
  --bg: #0b0f1e;
  --bg-soft: #111a33;
  --card: rgba(255, 255, 255, 0.055);
  --card-strong: rgba(255, 255, 255, 0.09);
  --border: rgba(255, 255, 255, 0.09);
  --text: #eef2ff;
  --muted: #95a3c4;
  --primary: #7c5cff;
  --primary-2: #38b6ff;
  --grad: linear-gradient(135deg, #7c5cff 0%, #38b6ff 100%);
  --grad-warm: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
  --green: #34d399;
  --red: #f87171;
  --amber: #ffd166;
  --radius: 20px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --mono: 'Space Grotesk', ui-monospace, 'SF Mono', Menlo, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

body::before, body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  z-index: -1;
  pointer-events: none;
}
body::before {
  width: 520px; height: 520px;
  background: rgba(124, 92, 255, 0.22);
  top: -180px; left: -120px;
  animation: drift 16s ease-in-out infinite alternate;
}
body::after {
  width: 460px; height: 460px;
  background: rgba(56, 182, 255, 0.16);
  bottom: -160px; right: -120px;
  animation: drift 20s ease-in-out infinite alternate-reverse;
}

@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(60px, 40px) scale(1.15); }
}

a { color: var(--primary-2); text-decoration: none; }

/* ---------- Navbar ---------- */
.navbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px;
  background: rgba(11, 15, 30, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.nav-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.nav-brand .logo-icon { font-size: 26px; }
.nav-actions { display: flex; align-items: center; gap: 10px; }
.balance-pill {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 14px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 30px;
  font-weight: 600; font-size: 14px;
  font-family: var(--mono);
}
.balance-pill .paw { font-size: 15px; }

.btn-logout {
  padding: 8px 16px;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.25);
  border-radius: 30px;
  color: var(--red); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all .25s;
}
.btn-logout:hover { background: rgba(248, 113, 113, 0.22); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px;
  border-radius: 14px; border: none; cursor: pointer;
  font-size: 15px; font-weight: 600; font-family: inherit;
  transition: transform .15s, box-shadow .2s, background .2s, border-color .2s;
  text-align: center;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--grad); color: #fff;
  box-shadow: 0 8px 24px rgba(124, 92, 255, 0.35);
  width: 100%;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 30px rgba(124, 92, 255, 0.45); }
.btn-ghost {
  background: var(--card); border: 1px solid var(--border); color: var(--text);
}
.btn-ghost:hover { border-color: rgba(124, 92, 255, 0.55); background: var(--card-strong); }
.btn-warm {
  background: var(--grad-warm); color: #fff;
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.3);
  width: 100%;
}
.btn-warm:hover { transform: translateY(-1px); }
.btn-green { background: linear-gradient(135deg, #10b981, #34d399); color: #06281e; width: 100%; box-shadow: 0 8px 24px rgba(52, 211, 153, 0.3); }
.btn-danger { background: rgba(248, 113, 113, 0.14); border: 1px solid rgba(248, 113, 113, 0.3); color: var(--red); }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 11px; }

/* ---------- Inputs ---------- */
.field { margin-bottom: 16px; }
.field label {
  display: block; margin-bottom: 7px;
  font-size: 13px; font-weight: 500; color: var(--muted);
}
.input {
  width: 100%;
  padding: 13px 16px;
  background: rgba(11, 15, 30, 0.6);
  border: 1px solid var(--border);
  border-radius: 13px;
  color: var(--text); font-size: 15px; font-family: inherit;
  transition: border-color .2s, box-shadow .2s;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.15); }
.input::placeholder { color: rgba(149, 163, 196, 0.5); }
.input-mono { font-family: var(--mono); letter-spacing: 1px; }

select.input { cursor: pointer; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }

.error-msg { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 10px; text-align: center; }
.success-msg { color: var(--green); font-size: 13px; min-height: 18px; margin-top: 10px; text-align: center; }

/* ---------- Auth ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.auth-box { width: 100%; max-width: 440px; }
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo .mark { font-size: 54px; display: block; margin-bottom: 6px; filter: drop-shadow(0 8px 24px rgba(124, 92, 255, 0.5)); }
.auth-logo h1 {
  font-size: 30px; font-weight: 800; letter-spacing: -0.5px;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.auth-logo p { color: var(--muted); font-size: 14px; margin-top: 6px; }

.auth-card {
  background: var(--card); border: 1px solid var(--border);
  backdrop-filter: blur(20px);
  border-radius: var(--radius); padding: 30px;
  box-shadow: var(--shadow);
}
.tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  background: rgba(11, 15, 30, 0.5);
  border-radius: 14px; padding: 5px; margin-bottom: 26px;
}
.tab {
  padding: 11px; text-align: center;
  background: transparent; border: none; border-radius: 11px;
  color: var(--muted); font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all .25s; font-family: inherit;
}
.tab.active { background: var(--grad); color: #fff; box-shadow: 0 6px 18px rgba(124, 92, 255, 0.35); }

.form-panel { display: none; animation: fadeUp .3s ease; }
.form-panel.active { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.auth-foot { text-align: center; margin-top: 20px; color: var(--muted); font-size: 13px; }

/* ---------- Wallet layout ---------- */
.wallet-main { max-width: 980px; margin: 0 auto; padding: 24px 20px 120px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

/* Credit-card style */
.card-shell {
  position: relative;
  border-radius: 24px; padding: 26px;
  color: #fff; overflow: hidden;
  background: linear-gradient(135deg, #4b32d8 0%, #7c5cff 45%, #38b6ff 100%);
  box-shadow: 0 24px 60px rgba(78, 52, 224, 0.45);
  min-height: 200px;
}
.card-shell::before {
  content: ''; position: absolute; top: -90px; right: -70px;
  width: 260px; height: 260px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
}
.card-shell::after {
  content: ''; position: absolute; bottom: -120px; left: -40px;
  width: 240px; height: 240px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}
.card-top { display: flex; justify-content: space-between; align-items: flex-start; position: relative; z-index: 1; }
.card-brand { font-size: 15px; font-weight: 800; letter-spacing: 0.5px; display: flex; align-items: center; gap: 8px; }
.card-chip {
  width: 42px; height: 32px; border-radius: 7px;
  background: linear-gradient(135deg, #f6d365, #fda085);
  position: relative;
}
.card-chip::after {
  content: ''; position: absolute; inset: 6px 4px;
  border: 1px solid rgba(0,0,0,0.25); border-radius: 4px;
}
.card-number {
  font-family: var(--mono);
  font-size: 25px; letter-spacing: 2.5px; font-weight: 600;
  margin: 34px 0 22px; position: relative; z-index: 1;
  text-shadow: 0 2px 12px rgba(0,0,0,0.25);
}
.card-bottom { display: flex; justify-content: space-between; align-items: flex-end; position: relative; z-index: 1; }
.card-holder .lbl, .card-valid .lbl { font-size: 10px; letter-spacing: 1px; text-transform: uppercase; opacity: 0.75; }
.card-holder .val, .card-valid .val { font-family: var(--mono); font-size: 15px; font-weight: 600; }

/* Side panel */
.panel {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px;
  backdrop-filter: blur(14px);
}
.panel h3 { font-size: 15px; font-weight: 700; margin-bottom: 14px; display:flex; align-items:center; gap:8px; }

.balance-big { display: flex; align-items: center; gap: 12px; margin: 6px 0 18px; }
.balance-big .amount { font-size: 40px; font-weight: 800; font-family: var(--mono); letter-spacing: -1px; }
.balance-big .unit { font-size: 22px; }

.user-line { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.avatar {
  width: 52px; height: 52px; border-radius: 16px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; color: #fff;
  box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}
.profile {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; color: #fff;
}
.user-line .name { font-weight: 700; font-size: 17px; }
.user-line .sub { color: var(--muted); font-size: 13px; font-family: var(--mono); }

.action-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 22px 0 30px; }
.action-btn {
  display: flex; flex-direction: column; align-items: center; gap: 9px;
  padding: 18px 10px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; color: var(--text); cursor: pointer;
  font-size: 13px; font-weight: 600; font-family: inherit;
  transition: all .25s;
}
.action-btn:hover { transform: translateY(-3px); border-color: rgba(124, 92, 255, 0.6); background: var(--card-strong); }
.action-btn .ico { font-size: 26px; }

/* Mini stats */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 30px; }
.stat-cell { text-align: center; background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 16px 10px; }
.stat-cell .v { font-size: 20px; font-weight: 800; font-family: var(--mono); }
.stat-cell .k { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat-cell .ico { font-size: 20px; }

/* Transactions */
.tx-list { display: flex; flex-direction: column; }
.tx-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 6px; border-bottom: 1px solid var(--border);
}
.tx-item:last-child { border-bottom: none; }
.tx-ico {
  width: 46px; height: 46px; border-radius: 14px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 21px;
  background: var(--card-strong);
}
.tx-body { flex: 1; min-width: 0; }
.tx-desc { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-date { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tx-amt { font-family: var(--mono); font-weight: 700; font-size: 15px; white-space: nowrap; }
.tx-amt.in { color: var(--green); }
.tx-amt.out { color: var(--red); }

.empty { text-align: center; color: var(--muted); padding: 34px 0; font-size: 14px; }

/* ---------- Modals ---------- */
.modal {
  display: none; position: fixed; inset: 0; z-index: 300;
  justify-content: center; align-items: center;
  padding: 20px;
  background: rgba(5, 8, 18, 0.72);
  backdrop-filter: blur(8px);
}
.modal.active { display: flex; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-box {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 22px; padding: 26px;
  width: 100%; max-width: 430px;
  box-shadow: var(--shadow);
  max-height: 90vh; overflow: auto;
  animation: pop .25s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes pop { from { opacity: 0; transform: scale(.94) translateY(10px); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.modal-head h3 { font-size: 19px; }
.modal-x { background: none; border: none; color: var(--muted); font-size: 26px; cursor: pointer; line-height: 1; transition: color .2s; }
.modal-x:hover { color: var(--text); }

.receive-wallet {
  font-family: var(--mono); text-align: center;
  font-size: 19px; letter-spacing: 1.5px; font-weight: 700;
  background: rgba(11,15,30,.6); border: 1px dashed var(--border);
  border-radius: 14px; padding: 18px; margin: 14px 0;
}
.qr-box { text-align: center; margin-top: 16px; }
.qr-box img { width: 180px; height: 180px; border-radius: 14px; background: #fff; padding: 8px; margin-bottom: 12px; }

/* QR scanner area */
.scanner-wrap { position: relative; border-radius: 16px; overflow: hidden; margin-top: 14px; background: #000; min-height: 220px; }
.scanner-wrap video { width: 100%; display: block; }
.scanner-hint { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); color: var(--muted); font-size: 13px; text-align: center; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--bg-soft); border: 1px solid var(--border);
  padding: 13px 22px; border-radius: 14px;
  font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: all .3s; z-index: 500;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { border-color: rgba(52, 211, 153, 0.5); }
.toast.err { border-color: rgba(248, 113, 113, 0.5); }

/* ---------- Admin ---------- */
.admin-wrap { max-width: 1200px; margin: 0 auto; padding: 24px 20px 60px; }
.admin-login-box { max-width: 400px; margin: 10vh auto 0; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 18px; padding: 20px; display: flex; align-items: center; gap: 14px;
}
.stat-card .ico { font-size: 26px; width: 50px; height: 50px; background: var(--card-strong); border-radius: 14px; display: flex; align-items: center; justify-content: center; }
.stat-card .v { font-size: 22px; font-weight: 800; font-family: var(--mono); }
.stat-card .k { font-size: 12px; color: var(--muted); }

.admin-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 28px; }
@media (max-width: 760px) { .admin-cols { grid-template-columns: 1fr; } }

.user-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px; border-bottom: 1px solid var(--border);
}
.user-item:last-child { border-bottom: none; }
.user-item .meta { flex: 1; min-width: 0; }
.user-item .meta .u-name { font-weight: 600; font-size: 15px; }
.user-item .meta .u-wallet { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.user-item .meta .u-email { font-size: 12px; color: var(--muted); opacity: .7; }
.user-item .u-bal { font-family: var(--mono); font-weight: 700; color: var(--green); white-space: nowrap; }

/* ---------- Ludka casino ---------- */
.ludka-bg {
  background:
    radial-gradient(900px 500px at 80% -10%, rgba(245, 158, 11, 0.16), transparent 60%),
    radial-gradient(800px 500px at -10% 20%, rgba(239, 68, 68, 0.14), transparent 60%),
    var(--bg);
}
.ludka-wrap { max-width: 720px; margin: 0 auto; padding: 22px 16px 120px; }

.game-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 24px; overflow: hidden; backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}
.game-stage { position: relative; height: 320px; background: radial-gradient(500px 260px at 30% 110%, rgba(124,92,255,.22), transparent 70%), rgba(6,10,22,0.6); }
.game-stage canvas { width: 100%; height: 100%; display: block; }
.mult-big {
  position: absolute; top: 24px; left: 0; right: 0; text-align: center;
  pointer-events: none;
  font-family: var(--mono); font-weight: 800;
  font-size: 58px; text-shadow: 0 0 40px rgba(56, 182, 255, .6);
  letter-spacing: -2px;
}
.mult-big .x { font-size: 30px; color: var(--primary-2); }
.mult-big.running { color: #fff; }
.mult-big.crash { color: var(--red); text-shadow: 0 0 40px rgba(248,113,113,.6); }
.mult-big.waiting { color: var(--amber); font-size: 40px; }
.round-state {
  position: absolute; top: 16px; left: 20px;
  font-size: 12px; color: var(--muted); font-family: var(--mono);
}
.game-foot { display: flex; gap: 8px; padding: 14px 16px; border-top: 1px solid var(--border); background: rgba(11,15,30,.4); overflow-x: auto; }
.hist-chip {
  flex-shrink: 0; padding: 7px 13px; border-radius: 30px;
  font-family: var(--mono); font-weight: 700; font-size: 13px;
  background: var(--card-strong); border: 1px solid var(--border);
}
.hist-chip.danger { color: #fff; background: linear-gradient(135deg, #7c2d12, #b91c1c); }
.hist-chip.mid { color: #7c2d12; background: linear-gradient(135deg, #fde68a, #f59e0b); }
.hist-chip.low { color: #064e3b; background: linear-gradient(135deg, #a7f3d0, #34d399); }

.bet-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 20px; }
@media (max-width: 640px) { .bet-panel { grid-template-columns: 1fr; } }
.bet-presets { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin-bottom: 12px; }
.preset {
  padding: 10px; border-radius: 12px; cursor: pointer;
  background: var(--card-strong); border: 1px solid var(--border);
  color: var(--text); font-family: var(--mono); font-size: 14px; font-weight: 600;
  transition: all .2s; text-align: center;
}
.preset:hover, .preset.active { border-color: var(--primary); background: rgba(124,92,255,.18); }

.pl-list { display: flex; flex-direction: column; max-height: 210px; overflow: auto; padding: 6px; }
.pl-item { display: flex; align-items: center; gap: 12px; padding: 10px 6px; border-bottom: 1px solid var(--border); font-size: 14px; }
.pl-item .pv { width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; color:#fff; }
.pl-item .pamt { font-family: var(--mono); font-weight: 600; }
.pl-item .pmult { margin-left: auto; font-family: var(--mono); font-weight: 700; color: var(--green); }

.cashout-btn {
  position: absolute; bottom: 18px; right: 18px;
  padding: 14px 30px; border-radius: 16px; border: none; cursor: pointer;
  font-family: var(--mono); font-weight: 800; font-size: 18px; color: #06281e;
  background: linear-gradient(135deg, #34d399, #10b981);
  box-shadow: 0 10px 30px rgba(52,211,153,.45);
  animation: pulse 1.2s infinite;
  transition: transform .15s;
}
.cashout-btn:hover { transform: scale(1.04); }
@keyframes pulse { 0%,100% { box-shadow: 0 10px 30px rgba(52,211,153,.4);} 50% { box-shadow: 0 10px 44px rgba(52,211,153,.75);} }

/* ---------- Pay page ---------- */
.pay-wrap { max-width: 440px; margin: 0 auto; padding: 30px 18px 80px; }
.pay-merchant { display: flex; align-items: center; gap: 14px; padding: 18px; background: var(--card); border: 1px solid var(--border); border-radius: 18px; margin-bottom: 18px; }
.pay-merchant .txt .who { font-weight: 700; }
.pay-merchant .txt .card { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.amount-display {
  text-align: center; padding: 20px; margin: 6px 0 18px;
  background: var(--card); border: 1px solid var(--border); border-radius: 18px;
  font-family: var(--mono); font-size: 46px; font-weight: 800;
}
.amount-display.small { font-size: 26px; padding: 12px; }

/* ---------- Mobile bottom nav ---------- */
.mobile-nav { display: none; }
@media (max-width: 720px) {
  .mobile-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
    background: rgba(11,15,30,0.92); backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    padding: 10px 8px calc(10px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .mnav-item { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 14px; border: none; background: none; color: var(--muted); font-size: 11px; font-weight: 600; cursor: pointer; border-radius: 12px; font-family: inherit; transition: all .2s; }
  .mnav-item .mi { font-size: 22px; }
  .mnav-item.active { color: var(--primary-2); background: rgba(124,92,255,0.12); }
  .qr-scan-mobile { display: flex !important; }
}

.qr-scan-mobile { display: none; }
@media (min-width: 721px) { .qr-scan-mobile { display: none !important; } }

/* Utility */
.mt-16 { margin-top: 16px; } .mb-16 { margin-bottom: 16px; } .mt-8 { margin-top: 8px; }
.muted { color: var(--muted); } .mono { font-family: var(--mono); }
.center { text-align: center; }
.flex { display: flex; align-items: center; gap: 8px; }
.badge { display: inline-flex; align-items:center; gap:6px; padding: 6px 12px; border-radius: 30px; font-size: 12px; font-weight:600; background: var(--card-strong); border:1px solid var(--border); }
.hidden { display: none !important; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(124,92,255,.4); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }