@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;600;700&display=swap');

/* ─── VARIABLES ───────────────────────────────────────────── */
:root {
  --c-bg:        #0d0f18;
  --c-surface:   #13151f;
  --c-card:      #1a1d2e;
  --c-card2:     #1f2235;
  --c-border:    rgba(255,255,255,0.07);
  --c-purple:    #7c3aed;
  --c-purple-l:  #9f6ef5;
  --c-purple-gl: rgba(124,58,237,0.25);
  --c-green:     #10b981;
  --c-red:       #ef4444;
  --c-yellow:    #f59e0b;
  --c-text:      #e8eaf0;
  --c-muted:     #6b7280;
  --c-dim:       #374151;
  --font:        'Inter', sans-serif;
  --mono:        'JetBrains Mono', monospace;
  --r:           10px;
  --r-lg:        16px;
}

/* ─── RESET ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: var(--font); background: var(--c-bg); color: var(--c-text); line-height: 1.5; overflow-x: hidden; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; font-size: inherit; color: inherit; }
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
img, svg { display: block; }

/* ─── SCROLLBAR ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--c-surface); }
::-webkit-scrollbar-thumb { background: var(--c-dim); border-radius: 3px; }

/* ─── HEADER ──────────────────────────────────────────────── */
.header {
  position: fixed; top: 0; left: 0; right: 0; height: 60px; z-index: 200;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
}

.logo {
  display: flex; align-items: center; gap: 8px;
  font-size: 1.2rem; font-weight: 800; letter-spacing: -0.5px;
  cursor: pointer; user-select: none;
}
.logo-icon { font-size: 1.4rem; }
.logo-accent { color: var(--c-purple-l); }

.header-search {
  flex: 1; max-width: 340px; margin: 0 24px;
  display: flex; align-items: center; gap: 8px;
  background: var(--c-card); border: 1px solid var(--c-border);
  border-radius: var(--r); padding: 0 14px; height: 38px;
  transition: border-color .2s;
}
.header-search:focus-within { border-color: var(--c-purple); }
.header-search svg { color: var(--c-muted); flex-shrink: 0; }
.header-search input { flex: 1; background: none; border: none; outline: none; font-size: 0.9rem; color: var(--c-text); }
.header-search input::placeholder { color: var(--c-muted); }

.header-right { display: flex; align-items: center; gap: 10px; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--r); font-size: 0.85rem; font-weight: 600; transition: all .2s; }
.btn-ghost { color: var(--c-muted); }
.btn-ghost:hover { background: var(--c-card); color: var(--c-text); }
.btn-purple {
  background: var(--c-purple); color: #fff;
  box-shadow: 0 2px 12px var(--c-purple-gl);
}
.btn-purple:hover { background: var(--c-purple-l); transform: translateY(-1px); }
.btn-purple:active { transform: none; }
.btn-full { width: 100%; justify-content: center; padding: 12px; font-size: 1rem; }

.wallet-pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--c-card); border: 1px solid var(--c-border);
  border-radius: var(--r); padding: 6px 12px; cursor: pointer;
  transition: border-color .2s;
}
.wallet-pill:hover { border-color: var(--c-purple); }
.wallet-amount { font-family: var(--mono); font-size: 0.85rem; color: var(--c-green); font-weight: 600; }
.wallet-cur { font-size: 0.7rem; color: var(--c-muted); font-weight: 700; }

.avatar-btn {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--c-purple), var(--c-purple-l));
  font-weight: 700; font-size: 0.85rem; cursor: pointer;
  position: relative;
}
.user-menu-wrap { position: relative; }
.user-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0; min-width: 200px;
  background: var(--c-card2); border: 1px solid var(--c-border);
  border-radius: var(--r-lg); box-shadow: 0 8px 32px rgba(0,0,0,.4);
  overflow: hidden; display: none; z-index: 300;
}
.user-dropdown.open { display: block; }
.user-dropdown-header { padding: 14px 16px; border-bottom: 1px solid var(--c-border); }
.user-dropdown-name { font-weight: 700; }
.user-dropdown-vip { font-size: 0.75rem; color: var(--c-purple-l); margin-top: 2px; }
.user-dropdown a, .user-dropdown button {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; width: 100%; text-align: left;
  font-size: 0.875rem; color: var(--c-muted); transition: all .15s;
}
.user-dropdown a:hover, .user-dropdown button:hover { background: var(--c-card); color: var(--c-text); }
.signout-btn { color: var(--c-red) !important; }
.signout-btn:hover { background: rgba(239,68,68,.08) !important; }

/* ─── LAYOUT ──────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 60px; left: 0; bottom: 0; width: 220px;
  background: var(--c-surface); border-right: 1px solid var(--c-border);
  padding: 16px 0; z-index: 100; overflow-y: auto;
}
.sidebar-section-title {
  font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--c-muted); padding: 8px 20px 4px;
}
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px; font-size: 0.875rem; font-weight: 500;
  color: var(--c-muted); transition: all .15s; position: relative;
}
.nav-link:hover { color: var(--c-text); background: var(--c-card); }
.nav-link.active { color: var(--c-purple-l); background: rgba(124,58,237,.08); }
.nav-link.active::before {
  content: ''; position: absolute; left: 0; top: 4px; bottom: 4px;
  width: 3px; background: var(--c-purple); border-radius: 0 2px 2px 0;
}
.nav-badge {
  margin-left: auto; font-size: 0.6rem; font-weight: 700;
  padding: 2px 6px; border-radius: 4px; text-transform: uppercase;
}
.badge-hot { background: rgba(239,68,68,.15); color: var(--c-red); }
.badge-soon { background: rgba(245,158,11,.15); color: var(--c-yellow); }

.main { margin-left: 220px; margin-top: 60px; min-height: calc(100vh - 60px); padding: 32px; }

/* ─── HOME ────────────────────────────────────────────────── */
.home-hero {
  background: linear-gradient(135deg, var(--c-card) 0%, #1e1535 100%);
  border: 1px solid var(--c-border); border-radius: var(--r-lg);
  padding: 40px 48px; margin-bottom: 36px;
  display: flex; align-items: center; justify-content: space-between;
}
.hero-title { font-size: 2rem; font-weight: 800; line-height: 1.2; }
.hero-title span { color: var(--c-purple-l); }
.hero-sub { color: var(--c-muted); margin-top: 8px; font-size: 0.95rem; }
.hero-emoji { font-size: 5rem; }

.section-title { font-size: 0.9rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--c-muted); margin-bottom: 16px; }

.games-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
  max-width: 700px;
}

.game-card {
  background: var(--c-card); border: 1px solid var(--c-border);
  border-radius: var(--r-lg); padding: 28px 24px; cursor: pointer;
  transition: all .25s; text-align: center; position: relative; overflow: hidden;
}
.game-card::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, var(--c-purple), transparent);
  opacity: 0; transition: opacity .25s;
}
.game-card:hover { transform: translateY(-6px); border-color: var(--c-purple); box-shadow: 0 8px 24px rgba(0,0,0,.3); }
.game-card:hover::before { opacity: 0.06; }
.game-card-icon { font-size: 3rem; margin-bottom: 14px; transition: transform .25s; display: block; }
.game-card:hover .game-card-icon { transform: scale(1.12) rotate(4deg); }
.game-card-name { font-weight: 700; font-size: 1.05rem; }
.game-card-tag { font-size: 0.7rem; color: var(--c-purple-l); margin-top: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }

/* ─── GAME VIEW ───────────────────────────────────────────── */
.game-view {
  display: none; position: fixed;
  top: 60px; left: 220px; right: 0; bottom: 0; z-index: 150;
  background: var(--c-bg); flex-direction: column;
}
.game-view.open { display: flex; }

.game-topbar {
  height: 54px; background: var(--c-surface); border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; flex-shrink: 0;
}
.game-topbar-title { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1rem; }
.game-topbar-icon { font-size: 1.3rem; }
.game-topbar-tag { font-size: 0.7rem; color: var(--c-muted); font-weight: 500; }
.btn-close-game {
  display: flex; align-items: center; gap: 6px; padding: 7px 14px;
  background: var(--c-card); border: 1px solid var(--c-border);
  border-radius: var(--r); font-size: 0.825rem; font-weight: 600;
  color: var(--c-muted); transition: all .2s;
}
.btn-close-game:hover { border-color: var(--c-purple); color: var(--c-text); }

.game-body { flex: 1; display: flex; overflow: hidden; }

.game-panel {
  width: 280px; flex-shrink: 0;
  background: var(--c-surface); border-right: 1px solid var(--c-border);
  padding: 20px; display: flex; flex-direction: column; gap: 16px;
  overflow-y: auto;
}

.field-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--c-muted); margin-bottom: 6px; }
.number-input {
  display: flex; align-items: center;
  background: var(--c-bg); border: 1px solid var(--c-border);
  border-radius: var(--r); overflow: hidden; transition: border-color .2s;
}
.number-input:focus-within { border-color: var(--c-purple); }
.number-input input { flex: 1; background: none; border: none; outline: none; padding: 10px 12px; font-family: var(--mono); font-size: 0.9rem; }
.number-input .ni-btn { width: 36px; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--c-muted); font-size: 1.1rem; font-weight: 700; transition: all .15s; }
.number-input .ni-btn:hover { background: var(--c-card); color: var(--c-text); }

.quick-bets { display: flex; gap: 6px; }
.quick-bet-btn {
  flex: 1; padding: 6px 0; font-size: 0.75rem; font-weight: 600;
  background: var(--c-card2); border: 1px solid var(--c-border);
  border-radius: 6px; color: var(--c-muted); transition: all .15s;
}
.quick-bet-btn:hover { border-color: var(--c-purple); color: var(--c-purple-l); }

.btn-bet {
  padding: 14px; font-size: 1rem; font-weight: 800; border-radius: var(--r);
  background: var(--c-purple); color: #fff; text-transform: uppercase; letter-spacing: 1px;
  box-shadow: 0 4px 16px var(--c-purple-gl); transition: all .2s;
}
.btn-bet:hover { background: var(--c-purple-l); transform: translateY(-1px); }
.btn-bet:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.panel-stats { display: flex; flex-direction: column; gap: 8px; }
.stat-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--c-card); border: 1px solid var(--c-border);
  border-radius: var(--r); padding: 10px 14px;
}
.stat-row-label { font-size: 0.72rem; color: var(--c-muted); font-weight: 600; text-transform: uppercase; }
.stat-row-val { font-family: var(--mono); font-size: 0.9rem; font-weight: 700; }
.val-green { color: var(--c-green); }
.val-purple { color: var(--c-purple-l); }
.val-yellow { color: var(--c-yellow); }

.game-canvas {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 32px; overflow: hidden; position: relative;
}

/* ─── DICE GAME ───────────────────────────────────────────── */
.dice-display { text-align: center; }
.dice-number {
  font-family: var(--mono); font-size: 6rem; font-weight: 900;
  color: var(--c-purple-l); text-shadow: 0 0 60px var(--c-purple-gl);
  line-height: 1; transition: all .3s;
}
.dice-number.win { color: var(--c-green); text-shadow: 0 0 60px rgba(16,185,129,.3); }
.dice-number.lose { color: var(--c-red); text-shadow: 0 0 60px rgba(239,68,68,.3); }
.dice-label { margin-top: 12px; font-size: 1rem; color: var(--c-muted); font-weight: 500; }
.dice-label.win { color: var(--c-green); }
.dice-label.lose { color: var(--c-red); }

.dice-slider-wrap { margin-top: 32px; width: 100%; max-width: 420px; }
.dice-slider-track {
  height: 6px; border-radius: 3px; position: relative;
  background: linear-gradient(90deg, var(--c-red) 0%, var(--c-yellow) 40%, var(--c-green) 100%);
  margin-bottom: 4px;
}
.dice-slider-thumb {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  width: 18px; height: 18px; background: #fff; border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,.4); cursor: pointer;
}
.dice-slider-labels { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 0.7rem; color: var(--c-muted); }

/* ─── MINES ───────────────────────────────────────────────── */
.mines-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; width: 100%; max-width: 420px; }
.mine-tile {
  aspect-ratio: 1; border-radius: var(--r); border: 2px solid var(--c-dim);
  background: var(--c-card2); cursor: pointer; transition: all .2s;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
}
.mine-tile:hover:not(.revealed):not(.disabled) { border-color: var(--c-purple); background: var(--c-card); transform: scale(1.04); }
.mine-tile.revealed-gem { border-color: var(--c-green); background: rgba(16,185,129,.12); }
.mine-tile.revealed-bomb { border-color: var(--c-red); background: rgba(239,68,68,.12); animation: shake .3s ease; }
.mine-tile.disabled { cursor: not-allowed; opacity: .6; }

@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ─── LIMBO ───────────────────────────────────────────────── */
.limbo-display { text-align: center; }
.limbo-number {
  font-family: var(--mono); font-size: 7rem; font-weight: 900;
  color: var(--c-purple-l); text-shadow: 0 0 80px var(--c-purple-gl);
  line-height: 1; transition: all .4s;
}
.limbo-number.win { color: var(--c-green); text-shadow: 0 0 80px rgba(16,185,129,.4); }
.limbo-number.lose { color: var(--c-red); text-shadow: 0 0 80px rgba(239,68,68,.4); }
.limbo-label { margin-top: 14px; font-size: 1rem; color: var(--c-muted); }
.limbo-label.win { color: var(--c-green); font-weight: 700; }
.limbo-label.lose { color: var(--c-red); font-weight: 700; }

/* ─── MODALS ──────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  backdrop-filter: blur(6px); z-index: 500;
  display: none; align-items: center; justify-content: center;
}
.overlay.open { display: flex; }

.modal {
  background: var(--c-card2); border: 1px solid var(--c-border);
  border-radius: var(--r-lg); padding: 28px; width: 100%; max-width: 400px;
  position: relative; animation: modal-in .25s ease;
}
@keyframes modal-in { from { opacity:0; transform: scale(.95) translateY(10px); } }

.modal-close {
  position: absolute; top: 16px; right: 16px;
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: var(--c-card); color: var(--c-muted); font-size: 1.1rem; transition: all .15s;
}
.modal-close:hover { color: var(--c-text); background: var(--c-dim); }

.modal-tabs { display: flex; background: var(--c-bg); border-radius: var(--r); padding: 4px; gap: 4px; margin-bottom: 22px; }
.modal-tab {
  flex: 1; padding: 8px; border-radius: 8px; font-size: 0.875rem; font-weight: 600;
  color: var(--c-muted); transition: all .15s;
}
.modal-tab.active { background: var(--c-card2); color: var(--c-purple-l); }

.field-group { margin-bottom: 16px; }
.field-group label { display: block; font-size: 0.78rem; font-weight: 600; color: var(--c-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.field-input {
  display: flex; align-items: center; gap: 10px;
  background: var(--c-bg); border: 1px solid var(--c-border);
  border-radius: var(--r); padding: 0 14px; height: 46px; transition: border-color .2s;
}
.field-input:focus-within { border-color: var(--c-purple); }
.field-input svg { color: var(--c-muted); flex-shrink: 0; }
.field-input input { flex: 1; background: none; border: none; outline: none; font-size: 0.9rem; }

.form-error { color: var(--c-red); font-size: 0.82rem; margin-bottom: 12px; min-height: 18px; }

/* ─── TOASTS ──────────────────────────────────────────────── */
.toasts { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; }
.toast {
  background: var(--c-card2); border: 1px solid var(--c-border);
  border-radius: var(--r); padding: 12px 18px; font-size: 0.875rem;
  box-shadow: 0 4px 16px rgba(0,0,0,.3); animation: toast-in .3s ease;
  display: flex; align-items: center; gap: 10px; min-width: 240px;
}
@keyframes toast-in { from { opacity:0; transform: translateX(20px); } }
.toast.success { border-left: 3px solid var(--c-green); }
.toast.error   { border-left: 3px solid var(--c-red); }
.toast.info    { border-left: 3px solid var(--c-purple); }

/* ─── WALLET MODAL ────────────────────────────────────────── */
.balance-cards { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.balance-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--c-bg); border: 1px solid var(--c-border);
  border-radius: var(--r); padding: 12px 16px;
}
.balance-icon { width: 36px; height: 36px; border-radius: 8px; background: var(--c-purple); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.9rem; }
.balance-name { font-size: 0.78rem; color: var(--c-muted); }
.balance-amount { font-family: var(--mono); font-weight: 700; font-size: 0.9rem; }

/* ─── MISC ────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--c-border); margin: 4px 0; }
.page-title { font-size: 1.6rem; font-weight: 800; margin-bottom: 4px; }
.page-sub { color: var(--c-muted); margin-bottom: 28px; }
.coming-soon { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; min-height: 40vh; color: var(--c-muted); font-size: 1.1rem; }
.coming-soon .cs-icon { font-size: 4rem; }

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 16px; }
  .game-view { left: 0; }
  .header-search { display: none; }
  .hero-emoji { display: none; }
}