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

:root {
  --bg: #0a0e17;
  --bg-alt: #0d1220;
  --panel: #141b2b;
  --panel-light: #1c2438;
  --panel-lighter: #253052;
  --border: #2a3450;
  --text: #eef1fa;
  --text-dim: #8b94ac;
  --text-dimmer: #626d88;
  --gold: #f5b800;
  --gold-bright: #ffd23f;
  --green: #22c55e;
  --green-bright: #4ade80;
  --red: #ef4444;
  --red-bright: #f87171;
  --blue: #3b82f6;
  --purple: #a855f7;
  --shadow: 0 10px 30px rgba(0,0,0,0.45);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(245,184,0,0.08), transparent 60%),
    radial-gradient(1000px 500px at 100% 0%, rgba(168,85,247,0.10), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: 'Rubik', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }

::selection { background: var(--gold); color: #1a1200; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10,14,23,0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.logo {
  font-family: 'Righteous', cursive;
  font-size: 22px;
  letter-spacing: 0.5px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo .accent { color: var(--gold); }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 18px;
  cursor: pointer;
  margin-left: auto;
}

.main-nav {
  display: flex;
  gap: 4px;
  flex: 1;
  flex-wrap: wrap;
}

.main-nav a {
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-dim);
  transition: background 0.15s, color 0.15s;
}

.main-nav a:hover { color: var(--text); background: var(--panel-light); }
.main-nav a.active { color: var(--bg); background: var(--gold); }

.wallet {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 30px;
  white-space: nowrap;
}

.wallet-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dimmer);
}

.balance-amount {
  font-weight: 700;
  font-size: 16px;
  color: var(--gold-bright);
  font-variant-numeric: tabular-nums;
}

.btn-reset {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-reset:hover { border-color: var(--red); color: var(--red-bright); }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 20px 24px;
  text-align: center;
  color: var(--text-dimmer);
  font-size: 13px;
}
.site-footer strong { color: var(--text-dim); }

/* ---------- Layout ---------- */
main {
  flex: 1;
  width: 100%;
}

.page-wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 24px 60px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 10px;
  padding: 13px 22px;
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s, box-shadow 0.15s;
  color: #0c0f16;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; filter: grayscale(0.3); }

.btn-primary { background: linear-gradient(180deg, var(--gold-bright), var(--gold)); box-shadow: 0 6px 18px rgba(245,184,0,0.25); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }

.btn-green { background: linear-gradient(180deg, var(--green-bright), var(--green)); box-shadow: 0 6px 18px rgba(34,197,94,0.25); }
.btn-green:hover:not(:disabled) { filter: brightness(1.08); }

.btn-red { background: linear-gradient(180deg, var(--red-bright), var(--red)); color: #1a0505; box-shadow: 0 6px 18px rgba(239,68,68,0.25); }
.btn-red:hover:not(:disabled) { filter: brightness(1.08); }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
}
.btn-outline:hover:not(:disabled) { border-color: var(--gold); color: var(--gold-bright); }

.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 8px; }

/* ---------- Form controls ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dimmer);
  font-weight: 600;
}

.bet-input-group {
  display: flex;
  align-items: center;
  background: var(--bg-alt);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.15s;
}
.bet-input-group:focus-within { border-color: var(--gold); }
.bet-input-group .prefix { padding: 0 0 0 14px; color: var(--text-dimmer); font-weight: 600; }
.bet-input-group input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  padding: 12px 8px;
  font-family: inherit;
  min-width: 0;
}
.bet-input-group .bet-quick {
  display: flex;
}
.bet-input-group .bet-quick button {
  background: var(--panel-light);
  border: none;
  border-left: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0 12px;
  height: 46px;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
  transition: background 0.15s, color 0.15s;
}
.bet-input-group .bet-quick button:hover { background: var(--panel-lighter); color: var(--gold-bright); }

select.select-input {
  background: var(--bg-alt);
  border: 1.5px solid var(--border);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}
select.select-input:focus { border-color: var(--gold); }

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 4px;
  background: var(--panel-lighter);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--gold);
  cursor: pointer;
  border: 3px solid #1a1200;
  box-shadow: 0 0 0 2px var(--gold);
}
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--gold);
  cursor: pointer;
  border: 3px solid #1a1200;
}

/* ---------- Panels / cards ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.game-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  align-items: start;
}

.controls-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  position: sticky;
  top: 90px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stage-panel {
  background:
    radial-gradient(600px 300px at 50% 0%, rgba(255,255,255,0.03), transparent 60%),
    var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  min-height: 520px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.game-title {
  font-family: 'Righteous', cursive;
  font-size: 28px;
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.game-sub {
  color: var(--text-dim);
  margin: 0 0 24px;
  font-size: 14px;
}

.result-banner {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  padding: 10px 22px;
  border-radius: 30px;
  font-weight: 800;
  font-size: 15px;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
}
.result-banner.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.result-banner.win { background: rgba(34,197,94,0.18); color: var(--green-bright); border: 1px solid var(--green); }
.result-banner.lose { background: rgba(239,68,68,0.18); color: var(--red-bright); border: 1px solid var(--red); }
.result-banner.push { background: rgba(139,148,172,0.18); color: var(--text); border: 1px solid var(--border); }

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  font-size: 14px;
}
.stat-row .label { color: var(--text-dimmer); }
.stat-row .value { font-weight: 700; }

.divider { height: 1px; background: var(--border); margin: 16px 0; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-green { background: rgba(34,197,94,0.15); color: var(--green-bright); }
.badge-gold { background: rgba(245,184,0,0.15); color: var(--gold-bright); }
.badge-red { background: rgba(239,68,68,0.15); color: var(--red-bright); }
.badge-blue { background: rgba(59,130,246,0.15); color: #93c5fd; }

/* ---------- Mini leaderboard (lobby) ---------- */
.mini-leaderboard { margin-bottom: 32px; }
.mini-lb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.mini-lb-header h2 {
  margin: 0;
  font-size: 18px;
  font-family: 'Righteous', cursive;
  font-weight: 400;
}
.mini-lb-link {
  font-size: 13px;
  font-weight: 700;
  color: var(--gold-bright);
}
.mini-lb-link:hover { text-decoration: underline; }

.mini-lb-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mini-lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.mini-lb-rank {
  font-weight: 800;
  width: 30px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
  flex-shrink: 0;
}
.mini-lb-rank.gold { color: #ffd23f; font-size: 18px; }
.mini-lb-rank.silver { color: #cfd8e3; font-size: 16px; }
.mini-lb-rank.bronze { color: #d98a4d; font-size: 16px; }

.mini-lb-name {
  flex: 1;
  font-weight: 700;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mini-lb-name .you-tag {
  margin-left: 6px;
  font-size: 9px;
  background: var(--gold);
  color: #1a1200;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 800;
  vertical-align: middle;
}
.mini-lb-balance {
  font-weight: 800;
  color: var(--gold-bright);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.mini-lb-loading, .mini-lb-empty {
  text-align: center;
  color: var(--text-dim);
  padding: 20px;
  font-size: 14px;
}

/* ---------- Lobby ---------- */
.hero {
  text-align: center;
  padding: 60px 24px 40px;
}
.hero h1 {
  font-family: 'Righteous', cursive;
  font-size: clamp(32px, 5vw, 56px);
  margin: 0 0 12px;
  background: linear-gradient(180deg, #fff, var(--gold-bright));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero p { color: var(--text-dim); font-size: 17px; max-width: 560px; margin: 0 auto 26px; }

.hero-balance {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 14px 26px;
  border-radius: 40px;
  box-shadow: var(--shadow);
}
.hero-balance .balance-amount { font-size: 26px; }

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 22px;
  margin-top: 20px;
}

.game-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  display: flex;
  flex-direction: column;
}
.game-card:hover {
  transform: translateY(-6px);
  border-color: var(--gold);
  box-shadow: 0 16px 40px rgba(0,0,0,0.5);
}
.game-card .thumb {
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  position: relative;
}
.game-card .thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,0.35));
}
.thumb-mines { background: linear-gradient(135deg, #1f2a1f, #14351f); }
.thumb-plinko { background: linear-gradient(135deg, #241f35, #2d1f45); }
.thumb-blackjack { background: linear-gradient(135deg, #2a1618, #3a1c22); }
.thumb-slots { background: linear-gradient(135deg, #2a2312, #3a2c12); }
.thumb-dice { background: linear-gradient(135deg, #162a2e, #123339); }
.thumb-roulette { background: linear-gradient(135deg, #2a1220, #3a1030); }
.thumb-keno { background: linear-gradient(135deg, #12242a, #0f3339); }
.thumb-scratch { background: linear-gradient(135deg, #241c10, #35280f); }

.game-card .info { padding: 18px 18px 20px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.game-card h3 { margin: 0; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.game-card p { margin: 0; color: var(--text-dim); font-size: 13.5px; flex: 1; }
.game-card .play-btn {
  margin-top: 10px;
  text-align: center;
  padding: 10px;
  border-radius: 8px;
  background: var(--panel-light);
  font-weight: 700;
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}
.game-card:hover .play-btn { background: var(--gold); color: #1a1200; }

.info-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 50px;
}
.info-strip .panel { text-align: center; }
.info-strip .panel .big { font-size: 28px; font-weight: 800; color: var(--gold-bright); }
.info-strip .panel .lbl { color: var(--text-dim); font-size: 13px; margin-top: 4px; }

/* ---------- Player stats card ---------- */
.stats-card { margin-top: 50px; }
.stats-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.stats-card-header h2 {
  margin: 0;
  font-size: 20px;
  font-family: 'Righteous', cursive;
  font-weight: 400;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}
.stat-tile {
  text-align: center;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 12px;
}
.stat-tile .big { font-size: 24px; font-weight: 800; color: var(--gold-bright); }
.stat-tile .lbl { color: var(--text-dim); font-size: 12px; margin-top: 4px; }

/* ---------- Share modal ---------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5,7,12,0.8);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 560px;
  width: 100%;
  box-shadow: var(--shadow);
}
.modal-card canvas {
  width: 100%;
  height: auto;
  border-radius: 10px;
  display: block;
  margin-bottom: 16px;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--panel-light);
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.modal-close:hover { color: var(--text); border-color: var(--gold); }
.modal-actions {
  display: flex;
  gap: 10px;
}

/* ---------- Auth ---------- */
.auth-gate {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-gate-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: auth-spin 0.8s linear infinite;
}
@keyframes auth-spin { to { transform: rotate(360deg); } }

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 30px;
  white-space: nowrap;
}
.user-email {
  font-size: 12px;
  color: var(--text-dim);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 999;
}
.toast {
  background: var(--panel-light);
  border: 1px solid var(--border);
  border-left: 4px solid var(--gold);
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
  animation: toast-in 0.25s ease;
  max-width: 300px;
}
.toast.win { border-left-color: var(--green); }
.toast.lose { border-left-color: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px);} to { opacity: 1; transform: translateX(0);} }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .game-shell { grid-template-columns: 1fr; }
  .controls-panel { position: static; }
}

@media (max-width: 760px) {
  .nav-toggle { display: block; }
  .main-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-alt);
    border-bottom: 1px solid var(--border);
    padding: 10px;
    flex-direction: column;
  }
  .main-nav.open { display: flex; }
  .header-inner { flex-wrap: wrap; position: relative; }
  .wallet { margin-left: auto; }
}
