:root {
  --bg: #0e1a24;
  --bg-2: #13232f;
  --panel: #1a2c38;
  --panel-2: #213743;
  --input: #0f212e;
  --line: #2f4553;
  --text: #ffffff;
  --muted: #b1bad3;
  --dim: #6b8496;
  --green: #00e701;
  --green-dark: #00b801;
  --red: #ff4e4e;
  --gold: #ffc94a;
  --blue: #1475e1;
  --purple: #9b5cff;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:disabled { cursor: not-allowed; opacity: .5; }
input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
.green { color: var(--green); }
.red { color: var(--red); }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 8px; font-weight: 700;
  background: var(--panel-2); transition: transform .08s, background .15s, filter .15s;
}
.btn:hover:not(:disabled) { filter: brightness(1.15); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn.primary { background: var(--green); color: #05220a; }
.btn.danger { background: var(--red); color: #2a0707; }
.btn.gold { background: var(--gold); color: #2a1d00; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.big { width: 100%; padding: 14px; font-size: 15px; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.icon-btn { font-size: 20px; padding: 6px 10px; border-radius: 8px; }
.input {
  width: 100%; background: var(--input); border: 2px solid var(--line);
  border-radius: 8px; padding: 9px 11px; outline: none; transition: border-color .15s;
}
.input:focus { border-color: var(--dim); }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 28px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { color: var(--muted); font-size: 12px; font-weight: 600; display: flex; justify-content: space-between; }
.wager { display: flex; background: var(--input); border: 2px solid var(--line); border-radius: 8px; overflow: hidden; }
.wager input { flex: 1; min-width: 0; background: transparent; border: 0; padding: 9px 11px; outline: none; }
.wager .chip { padding: 0 12px; background: var(--panel-2); border-left: 1px solid var(--line); font-weight: 700; color: var(--muted); }
.wager .chip:hover { color: #fff; }
.seg { display: flex; background: var(--input); border-radius: 8px; padding: 3px; gap: 3px; }
.seg button { flex: 1; padding: 8px 4px; border-radius: 6px; font-weight: 600; color: var(--muted); font-size: 13px; }
.seg button.active { background: var(--panel-2); color: #fff; }
input[type=number]::-webkit-inner-spin-button { opacity: .4; }

/* ---------- Auth ---------- */
.auth { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1000px 600px at 20% 0%, #1f3a4d 0%, transparent 60%), radial-gradient(800px 500px at 100% 100%, #1b3324 0%, transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 380px; background: var(--panel); border-radius: 16px; padding: 28px; box-shadow: 0 30px 80px rgba(0,0,0,.4); }
.auth-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.auth-card label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-weight: 600; font-size: 12px; }
.auth-error { color: var(--red); min-height: 18px; font-size: 13px; }
.tabs { display: flex; gap: 4px; background: var(--input); padding: 4px; border-radius: 10px; margin-top: 18px; }
.tab { flex: 1; padding: 9px; border-radius: 7px; font-weight: 700; color: var(--muted); }
.tab.active { background: var(--panel-2); color: #fff; }

/* ---------- Layout ---------- */
.logo { font-weight: 800; font-size: 19px; letter-spacing: -.3px; text-decoration: none; color: #fff; display: block; padding: 4px 6px 18px; }
.logo span { color: var(--green); }
.logo.big { font-size: 26px; padding: 0 0 6px; }
.app { display: flex; min-height: 100vh; }
.sidebar { width: 230px; flex-shrink: 0; background: var(--bg-2); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.nav-section { color: var(--dim); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; padding: 14px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 600; }
.nav-item:hover { background: var(--panel); color: #fff; }
.nav-item.active { background: var(--panel-2); color: #fff; }
.nav-item .ic { width: 22px; text-align: center; font-size: 16px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: var(--bg-2); border-bottom: 1px solid #0a141c; position: sticky; top: 0; z-index: 10; }
.menu-btn { display: none; }
.balance { display: flex; align-items: center; gap: 8px; background: var(--input); padding: 8px 14px; border-radius: 8px; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 15px; transition: box-shadow .3s; }
.balance .coin { color: var(--gold); font-size: 12px; }
.balance.up { box-shadow: 0 0 0 2px var(--green); }
.balance.down { box-shadow: 0 0 0 2px #ff4e4e55; }
.user { font-weight: 700; color: var(--muted); }
.user:hover { color: #fff; text-decoration: underline; }
.sound-ctl { display: flex; align-items: center; gap: 2px; }
.sound-ctl input[type=range] { width: 80px; accent-color: var(--green); }
@media (max-width: 760px) { .sound-ctl input[type=range] { display: none; } }
#view { padding: 24px; max-width: 1280px; width: 100%; margin: 0 auto; }

/* ---------- Lobby ---------- */
.hero { border-radius: 16px; padding: 28px; margin-bottom: 24px;
  background: linear-gradient(120deg, #1d4b2c 0%, #1a3b52 55%, #3a2260 100%); position: relative; overflow: hidden; }
.hero h1 { margin: 0 0 6px; font-size: 28px; letter-spacing: -.5px; }
.hero p { margin: 0; color: #d6e2ea; }
.hero .hero-stats { display: flex; gap: 12px; margin-top: 18px; flex-wrap: wrap; }
.hero .pill { background: rgba(0,0,0,.25); padding: 8px 12px; border-radius: 8px; font-weight: 600; }
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.game-card { position: relative; aspect-ratio: 3/4; border-radius: 14px; padding: 16px; text-decoration: none; color: #fff;
  display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; transition: transform .15s, box-shadow .15s; }
.game-card:hover { transform: translateY(-4px); box-shadow: 0 14px 30px rgba(0,0,0,.35); }
.game-card .gc-icon { position: absolute; top: 18%; left: 50%; transform: translateX(-50%); font-size: 64px; filter: drop-shadow(0 8px 14px rgba(0,0,0,.35)); }
.game-card .gc-name { font-weight: 800; font-size: 18px; text-transform: uppercase; letter-spacing: .5px; }
.game-card .gc-desc { font-size: 12px; color: rgba(255,255,255,.75); margin-top: 2px; }

/* ---------- Game layout ---------- */
.game { display: grid; grid-template-columns: 300px 1fr; background: var(--panel); border-radius: 14px; overflow: hidden; min-height: 560px; }
.game-panel { background: var(--panel); padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.game-stage { background: var(--bg-2); position: relative; padding: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; min-width: 0; }
.game-title { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-size: 20px; }
.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-box { background: var(--input); border-radius: 8px; padding: 8px 10px; }
.stat-box .k { color: var(--muted); font-size: 11px; font-weight: 600; }
.stat-box .v { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.history { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; width: 100%; min-height: 28px; }
.history .h { padding: 5px 10px; border-radius: 999px; font-weight: 700; font-size: 12px; background: var(--panel-2); font-variant-numeric: tabular-nums; animation: pop .25s ease; }
.history .h.win { background: var(--green); color: #05220a; }
.history .h.lose { background: var(--panel-2); color: var(--muted); }
.result-banner { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(.9); background: var(--panel); border: 3px solid var(--green);
  border-radius: 14px; padding: 16px 26px; text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,.5); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 5; }
.result-banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.result-banner .rb-m { color: var(--green); font-size: 26px; font-weight: 800; }
.result-banner .rb-p { color: var(--muted); font-weight: 700; margin-top: 4px; }
.result-banner.lose { border-color: var(--red); }
.result-banner.lose .rb-m { color: var(--red); }

@keyframes pop { from { transform: scale(.6); } to { transform: scale(1); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes flip { from { transform: rotateY(90deg); } to { transform: rotateY(0); } }

/* Dice */
.dice-result { font-size: 64px; font-weight: 800; font-variant-numeric: tabular-nums; transition: color .2s; }
.dice-track-wrap { width: 100%; max-width: 640px; background: var(--panel-2); border-radius: 999px; padding: 18px 22px; position: relative; }
.dice-track { height: 10px; border-radius: 999px; position: relative; }
.dice-range { position: absolute; inset: 10px 22px; width: calc(100% - 44px); margin: 0; height: 30px; opacity: 0; cursor: grab; }
.dice-thumb { position: absolute; top: 50%; width: 30px; height: 30px; transform: translate(-50%, -50%); background: var(--blue); border-radius: 6px; box-shadow: 0 4px 10px rgba(0,0,0,.4); pointer-events: none; }
.dice-marker { position: absolute; bottom: 30px; transform: translateX(-50%); transition: left .35s cubic-bezier(.2,.9,.3,1.2); }
.dice-marker .dm { background: #fff; color: #0e1a24; font-weight: 800; padding: 8px 10px; border-radius: 8px; font-variant-numeric: tabular-nums; position: relative; }
.dice-marker .dm::after { content: ''; position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%); border: 6px solid transparent; border-bottom: 0; border-top-color: #fff; }
.dice-marker.win .dm { background: var(--green); } .dice-marker.win .dm::after { border-top-color: var(--green); }
.dice-marker.lose .dm { background: var(--red); color: #fff; } .dice-marker.lose .dm::after { border-top-color: var(--red); }
.dice-scale { display: flex; justify-content: space-between; width: 100%; max-width: 640px; color: var(--muted); font-weight: 600; padding: 0 22px; font-size: 12px; }

/* Limbo */
.limbo-num { font-size: 96px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -2px; }
.limbo-num.win { color: var(--green); } .limbo-num.lose { color: var(--red); }

/* Crash / Plinko canvas */
.canvas-wrap { width: 100%; flex: 1; position: relative; min-height: 380px; }
.canvas-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* Mines & Towers tiles */
.mines-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; width: 100%; max-width: 480px; aspect-ratio: 1; }
.tile { background: var(--panel-2); border-radius: 10px; box-shadow: 0 5px 0 #182b36; display: grid; place-items: center; font-size: 34px; transition: transform .1s, background .15s; user-select: none; }
.tile.clickable:hover { transform: translateY(-3px); background: #2c4655; }
.tile.revealed { background: #0a161e; box-shadow: inset 0 0 0 2px #2a4352; animation: pop .2s ease; }
.tile.revealed.dim { opacity: .5; animation: none; }
.tile.boom { background: #4a1c22; animation: shake .3s; }
.tile .gem { filter: drop-shadow(0 0 10px #00e70188); }
.towers { display: flex; flex-direction: column-reverse; gap: 8px; width: 100%; max-width: 520px; }
.tower-row { display: grid; grid-template-columns: 70px 1fr; gap: 8px; align-items: center; }
.tower-row .tm { color: var(--muted); font-weight: 700; font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.tower-row .tiles { display: grid; gap: 8px; }
.tower-row .tile { height: 44px; font-size: 22px; border-radius: 8px; }
.tower-row.current .tile.clickable { background: #2a5a3f; box-shadow: 0 5px 0 #173826; }
.tower-row.current .tm { color: var(--green); }

/* Keno */
.keno-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; width: 100%; max-width: 620px; }
.keno-tile { aspect-ratio: 1; border-radius: 8px; background: var(--panel-2); box-shadow: 0 4px 0 #182b36; font-weight: 800; font-size: 16px; transition: transform .1s, background .15s; }
.keno-tile:hover:not(:disabled) { transform: translateY(-2px); }
.keno-tile.picked { background: var(--purple); box-shadow: 0 4px 0 #5e2fb0; }
.keno-tile.drawn { background: var(--input); box-shadow: none; color: var(--red); animation: pop .2s; }
.keno-tile.hit { background: var(--green); color: #05220a; box-shadow: 0 4px 0 var(--green-dark); animation: pop .25s; }
.keno-tile:disabled { opacity: 1; cursor: default; }
.payout-strip { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; width: 100%; max-width: 620px; }
.payout-strip .ps { flex: 1; min-width: 52px; background: var(--panel-2); border-radius: 6px; padding: 6px 4px; text-align: center; font-size: 12px; font-weight: 700; }
.payout-strip .ps small { display: block; color: var(--muted); font-weight: 600; font-size: 10px; }
.payout-strip .ps.hit { background: var(--green); color: #05220a; } .payout-strip .ps.hit small { color: #05220a; }

/* Cards */
.card { width: 86px; height: 122px; border-radius: 9px; background: #fff; color: #1a1a1a; position: relative; box-shadow: 0 6px 16px rgba(0,0,0,.35); flex-shrink: 0; font-weight: 800; }
.card .cr { position: absolute; top: 7px; left: 9px; font-size: 22px; line-height: 1; text-align: center; }
.card .cr small { display: block; font-size: 18px; }
.card .cs { position: absolute; bottom: 6px; right: 10px; font-size: 34px; }
.card.red { color: #e0202e; }
.card.back { background: repeating-linear-gradient(45deg, #1475e1 0 8px, #105fb8 8px 16px); border: 4px solid #fff; }
.card.deal { animation: dealIn .3s ease; }
.card.big { width: 120px; height: 170px; } .card.big .cr { font-size: 30px; } .card.big .cs { font-size: 50px; }
.card.mini { width: 48px; height: 68px; border-radius: 6px; } .card.mini .cr { font-size: 14px; top: 4px; left: 5px; } .card.mini .cr small { font-size: 11px; } .card.mini .cs { font-size: 18px; bottom: 2px; right: 5px; }
.card.mini.lost { outline: 3px solid var(--red); } .card.mini.won { outline: 3px solid var(--green); }
@keyframes dealIn { from { transform: translateY(-40px) rotate(-8deg); opacity: 0; } to { transform: none; opacity: 1; } }
.bj-area { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.bj-cards { display: flex; gap: 0; }
.bj-cards .card + .card { margin-left: -40px; }
.bj-value { background: var(--panel-2); padding: 4px 12px; border-radius: 999px; font-weight: 800; font-variant-numeric: tabular-nums; }
.bj-value.bust { background: var(--red); } .bj-value.bj { background: var(--gold); color: #2a1d00; }
.bj-hands { display: flex; gap: 36px; flex-wrap: wrap; justify-content: center; }
.bj-hand { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px; border-radius: 12px; border: 2px solid transparent; }
.bj-hand.active { border-color: var(--green); background: rgba(0,231,1,.05); }
.bj-hand .res { font-weight: 800; font-size: 13px; text-transform: uppercase; }
.bj-label { color: var(--dim); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.hilo-row { display: flex; align-items: center; gap: 24px; }
.hilo-hint { color: var(--muted); font-weight: 600; font-size: 12px; text-align: center; max-width: 120px; }
.hilo-history { display: flex; gap: 6px; overflow-x: auto; width: 100%; padding: 6px 2px; min-height: 82px; justify-content: center; }

/* ---------- Leaderboard ---------- */
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 24px; }
.lb-layout { display: grid; grid-template-columns: 1fr 340px; gap: 18px; }
.lb-layout > * { min-width: 0; }
@media (max-width: 1100px) { .lb-layout { grid-template-columns: 1fr; } }
.panel { background: var(--panel); border-radius: 14px; padding: 16px; overflow: hidden; }
.panel h2 { margin: 0 0 12px; font-size: 16px; }
.podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; align-items: end; }
.podium .pod { background: var(--panel-2); border-radius: 12px; padding: 14px; text-align: center; }
.podium .pod .medal { font-size: 30px; }
.podium .pod .pn { font-weight: 800; font-size: 16px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium .pod .pv { color: var(--green); font-weight: 700; font-variant-numeric: tabular-nums; }
.podium .pod.first { padding-top: 24px; background: linear-gradient(180deg, #4a3b10, var(--panel-2)); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { text-align: left; color: var(--muted); font-size: 12px; font-weight: 600; padding: 8px 10px; white-space: nowrap; }
th.sortable { cursor: pointer; } th.sortable:hover { color: #fff; } th.sorted { color: var(--green); }
td { padding: 10px; border-top: 1px solid #ffffff0d; white-space: nowrap; }
tr.me td { background: rgba(0,231,1,.06); }
td.num, th.num { text-align: right; }
.rank { color: var(--dim); font-weight: 800; }
.feed { display: flex; flex-direction: column; gap: 6px; max-height: 620px; overflow-y: auto; }
.feed-item { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: center; background: var(--panel-2); padding: 8px 10px; border-radius: 8px; font-size: 13px; }
.feed-item .fi-g { font-size: 18px; }
.feed-item .fi-n { font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.feed-item .fi-s { color: var(--muted); font-size: 11px; }
.feed-item .fi-p { text-align: right; font-weight: 700; }
.cards4 { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--panel-2); border-left: 4px solid var(--blue); padding: 12px 16px; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.4); font-weight: 600; animation: pop .2s; max-width: 320px; }
.toast.error { border-color: var(--red); }
.toast.win { border-color: var(--green); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .game { grid-template-columns: 1fr; }
  .game-stage { order: -1; min-height: 420px; }
  .lb-layout { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; box-shadow: 10px 0 40px rgba(0,0,0,.5); }
  .sidebar.open { transform: none; }
  .menu-btn { display: block; }
  .topbar { padding: 10px 16px; gap: 8px; }
  .user { display: none; }
  #view { padding: 16px; }
  .keno-grid { gap: 5px; }
  .mines-grid { gap: 6px; }
  .tile { font-size: 26px; }
  .limbo-num { font-size: 64px; }
  .card { width: 70px; height: 100px; } .card .cs { font-size: 26px; }
  .card.big { width: 96px; height: 136px; }
  .podium .pod { padding: 10px 6px; }
}
