:root {
  --fxg-bg: #08080f;
  --fxg-bg-2: #0e0e1a;
  --fxg-panel: rgba(255, 255, 255, 0.04);
  --fxg-panel-2: rgba(255, 255, 255, 0.06);
  --fxg-border: rgba(255, 255, 255, 0.1);
  --fxg-text: #eef2ff;
  --fxg-muted: rgba(232, 242, 255, 0.55);
  --fxg-primary: #8b5cf6;
  --fxg-accent: #f472b6;
  --fxg-cyan: #22d3ee;
  --fxg-gold: #fbbf24;
  --fxg-success: #34d399;
  --fxg-danger: #fb7185;
  --fxg-radius: 18px;
  --fxg-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  --fxg-shadow-sm: 0 10px 26px rgba(0, 0, 0, 0.35);
  --fxg-font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--fxg-font);
  background:
    radial-gradient(ellipse 90% 60% at 50% -20%, rgba(139,92,246,0.16) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 100% 0%, rgba(34,211,238,0.07) 0%, transparent 60%),
    linear-gradient(180deg, var(--fxg-bg) 0%, var(--fxg-bg-2) 100%);
  background-attachment: fixed;
  color: var(--fxg-text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(139,92,246,0.45); border-radius: 3px; }
::selection { background: rgba(139,92,246,0.4); color: #fff; }

#fxgToast { position: fixed; top: 84px; right: 16px; z-index: 999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.fxg-toast-item {
  background: var(--fxg-panel);
  backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid var(--fxg-border);
  border-left: 3px solid var(--fxg-primary);
  border-radius: 14px;
  padding: 0.75rem 1rem;
  font-size: 0.8rem; font-weight: 700;
  box-shadow: var(--fxg-shadow-sm);
  animation: fxgToastIn 0.3s ease;
  max-width: 300px;
}
.fxg-toast-item.win { border-left-color: var(--fxg-success); }
.fxg-toast-item.error { border-left-color: var(--fxg-cyan); }
.fxg-toast-item.bonus { border-left-color: var(--fxg-gold); }
@keyframes fxgToastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }

/* ─── App layout ─── */
.fxg-app { min-height: 100vh; display: flex; flex-direction: column; padding-bottom: 120px; }

/* ─── Top bar ─── */
.fxg-top {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: rgba(8, 8, 15, 0.75);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  border-bottom: 1px solid var(--fxg-border);
}
.fxg-top-left { flex-shrink: 0; }
.fxg-back {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--fxg-muted); text-decoration: none;
  font-size: 0.75rem; font-weight: 700;
  padding: 0.4rem 0.7rem; border-radius: 12px;
  background: var(--fxg-panel); border: 1px solid var(--fxg-border);
  transition: all 0.2s;
}
.fxg-back:hover { color: var(--fxg-text); background: var(--fxg-panel-2); }
.fxg-ic { width: 18px; height: 18px; }
.fxg-ico { width: 26px; height: 26px; }
.fxg-ico-btn {
  width: 38px; height: 38px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--fxg-panel); border: 1px solid var(--fxg-border);
  color: var(--fxg-muted); cursor: pointer; transition: all 0.2s;
}
.fxg-ico-btn:hover { color: var(--fxg-text); background: var(--fxg-panel-2); }
.fxg-ico-btn.off { color: var(--fxg-danger); }

.fxg-top-title { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1rem; }
.fxg-top-title .fxg-ico { width: 30px; height: 30px; }
.fxg-logo {
  font-family: 'Unbounded', sans-serif;
  font-size: 1.1rem; font-weight: 800;
  background: linear-gradient(135deg, #a78bfa, #f472b6);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

.fxg-top-right { display: flex; align-items: center; gap: 0.5rem; }
.fxg-balance {
  display: flex; flex-direction: column; align-items: flex-end;
  padding: 0.25rem 0.75rem;
  background: linear-gradient(135deg, rgba(139,92,246,0.2), rgba(34,211,238,0.12));
  border: 1px solid rgba(139,92,246,0.3);
  border-radius: 12px;
  white-space: nowrap;
}
.fxg-balance-label { font-size: 0.55rem; font-weight: 600; color: var(--fxg-muted); letter-spacing: 0.4px; text-transform: uppercase; }
.fxg-balance-val { font-size: 0.92rem; font-weight: 900; color: var(--fxg-gold); line-height: 1.1; transition: transform 0.2s; }
.fxg-balance-val.up { color: var(--fxg-success); animation: fxgBalUp 0.6s ease; }
.fxg-balance-val.down { color: var(--fxg-danger); animation: fxgBalDown 0.6s ease; }
@keyframes fxgBalUp { 0% { transform: scale(1); } 40% { transform: scale(1.14); } 100% { transform: scale(1); } }
@keyframes fxgBalDown { 0% { transform: scale(1); } 40% { transform: scale(0.9); } 100% { transform: scale(1); } }
.fxg-balance-bonus { font-size: 0.6rem; font-weight: 700; color: var(--fxg-cyan); letter-spacing: 0.3px; }

.fxg-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0.55rem 1.1rem; border-radius: 13px;
  font-size: 0.8rem; font-weight: 800; font-family: inherit;
  border: 1px solid transparent; cursor: pointer;
  transition: all 0.2s; text-decoration: none;
}
.fxg-btn-p { background: linear-gradient(135deg, #8b5cf6, #7c3aed); color: #fff; box-shadow: 0 6px 18px rgba(139,92,246,0.35); }
.fxg-btn-p:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(139,92,246,0.45); }
.fxg-btn-g { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #1c1205; box-shadow: 0 6px 18px rgba(251,191,36,0.3); }
.fxg-btn-ghost { background: var(--fxg-panel); border-color: var(--fxg-border); color: var(--fxg-muted); }
.fxg-btn-ghost:hover { color: var(--fxg-text); background: var(--fxg-panel-2); }
.fxg-btn-ghost.active { color: var(--fxg-text); border-color: var(--fxg-primary); background: rgba(139,92,246,0.15); }
.fxg-btn-play {
  background: linear-gradient(135deg, #34d399, #10b981);
  color: #03281f; font-size: 1rem; padding: 0.75rem 2rem;
  border-radius: 15px; box-shadow: 0 8px 24px rgba(52,211,153,0.35);
}
.fxg-btn-play:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(52,211,153,0.5); }
.fxg-btn-play:disabled { opacity: 0.5; cursor: not-allowed; }
.fxg-btn-accent { background: linear-gradient(135deg, #f472b6, #fb7185); color: #fff; box-shadow: 0 6px 18px rgba(244,114,182,0.3); }
.fxg-btn-accent:hover:not(:disabled) { transform: translateY(-2px); }
.fxg-btn-sm { padding: 0.45rem 0.9rem; font-size: 0.72rem; border-radius: 11px; }

/* ─── Main area ─── */
.fxg-main {
  flex: 1; width: 100%; max-width: 720px; margin: 0 auto;
  padding: 1rem 1rem 0.5rem;
  display: flex; flex-direction: column; align-items: center;
}
.fxg-panel {
  width: 100%;
  background: var(--fxg-panel);
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  border: 1px solid var(--fxg-border);
  border-top-color: rgba(255,255,255,0.14);
  border-radius: var(--fxg-radius);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), var(--fxg-shadow-sm);
  overflow: hidden;
}

/* ─── HUD ─── */
.fxg-hud {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  padding: 0.6rem 1rem calc(0.6rem + env(safe-area-inset-bottom));
  background: rgba(8, 8, 15, 0.9);
  backdrop-filter: blur(24px) saturate(1.6);
  -webkit-backdrop-filter: blur(24px) saturate(1.6);
  border-top: 1px solid var(--fxg-border);
}
.fxg-hud-row {
  max-width: 720px; margin: 0 auto;
  display: flex; align-items: center; gap: 0.6rem;
}
.fxg-bet-field { flex-shrink: 0; }
.fxg-bet-field label { display: block; font-size: 0.55rem; font-weight: 700; color: var(--fxg-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 3px; }
.fxg-bet-input {
  display: flex; align-items: center;
  background: var(--fxg-panel);
  border: 1px solid var(--fxg-border);
  border-radius: 12px;
  overflow: hidden;
}
.fxg-bet-input input {
  width: 92px; padding: 0.55rem 0.4rem 0.55rem 0.7rem;
  background: transparent; border: none; outline: none;
  color: var(--fxg-text); font-family: inherit; font-size: 0.95rem; font-weight: 800;
}
.fxg-bet-x { padding: 0 0.6rem; color: var(--fxg-muted); font-size: 0.75rem; font-weight: 800; border-left: 1px solid var(--fxg-border); }
.fxg-bet-presets { display: flex; gap: 4px; flex: 1; justify-content: center; flex-wrap: wrap; }
.fxg-bet-presets .fxg-btn { padding: 0.5rem 0.7rem; font-size: 0.7rem; }
.fxg-bet-actions { flex-shrink: 0; }
.fxg-hud-extras { max-width: 720px; margin: 0.5rem auto 0; display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; }
.fxg-hud-chip {
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--fxg-panel); border: 1px solid var(--fxg-border);
  border-radius: 12px; padding: 0.4rem 0.75rem;
}
.fxg-hud-chip label { font-size: 0.62rem; font-weight: 700; color: var(--fxg-muted); }
.fxg-hud-chip input, .fxg-hud-chip select {
  background: rgba(255,255,255,0.05); border: 1px solid var(--fxg-border);
  color: var(--fxg-text); border-radius: 9px; padding: 0.4rem 0.5rem;
  font-family: inherit; font-weight: 700; font-size: 0.75rem;
}
.fxg-stat-chip {
  background: var(--fxg-panel); border: 1px solid var(--fxg-border);
  border-radius: 14px; padding: 0.7rem 1.2rem; text-align: center;
}
.fxg-stat-chip b { display: block; font-size: 1.1rem; font-weight: 900; color: var(--fxg-gold); }
.fxg-stat-chip span { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--fxg-muted); font-weight: 700; }

/* ─── Hub ─── */
.fxg-hub {
  width: 100%; max-width: 860px; margin: 0 auto;
  padding: 1.4rem 1rem 3rem;
}
.fxg-hub-head { text-align: center; margin-bottom: 1.6rem; }
.fxg-hub-head h1 { font-size: 1.7rem; font-weight: 900; }
.fxg-hub-head p { color: var(--fxg-muted); font-size: 0.85rem; margin-top: 0.3rem; }
.fxg-hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.8rem; }
.fxg-game-card {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 1.4rem 0.9rem;
  background: var(--fxg-panel);
  border: 1px solid var(--fxg-border);
  border-radius: var(--fxg-radius);
  text-decoration: none; color: var(--fxg-text);
  transition: all 0.25s;
  position: relative; overflow: hidden;
  --card-c: #8b5cf6;
}
.fxg-game-card::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 70%;
  background: radial-gradient(circle at 50% 20%, color-mix(in srgb, var(--card-c) 22%, transparent), transparent 70%);
  opacity: 0.6; pointer-events: none;
}
.fxg-game-card:hover { transform: translateY(-4px); border-color: color-mix(in srgb, var(--card-c) 55%, transparent); box-shadow: 0 18px 36px rgba(0,0,0,0.45); }
.fxg-game-card .fxg-ico { width: 52px; height: 52px; }
.fxg-game-card-name { font-weight: 800; font-size: 0.95rem; }
.fxg-game-card-desc { font-size: 0.7rem; color: var(--fxg-muted); text-align: center; line-height: 1.35; }

/* ─── Auth ─── */
.fxg-auth { text-align: center; padding: 3rem 1rem; }
.fxg-auth-ico { width: 56px; height: 56px; color: var(--fxg-primary); }
.fxg-auth h2 { font-size: 1.3rem; font-weight: 900; margin: 0.8rem 0 0.3rem; }
.fxg-auth p { color: var(--fxg-muted); font-size: 0.85rem; max-width: 340px; margin: 0 auto 1.2rem; }
.fxg-auth-actions { display: flex; gap: 0.6rem; justify-content: center; }

/* ─── Responsive ─── */
@media (max-width: 560px) {
  .fxg-back span { display: none; }
  .fxg-back { font-size: 0; padding: 0.45rem; }
  .fxg-bet-input input { width: 74px; }
  .fxg-bet-presets .fxg-btn { padding: 0.45rem 0.5rem; font-size: 0.62rem; }
  .fxg-btn-play { padding: 0.7rem 1.4rem; font-size: 0.9rem; }
  .fxg-hub-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .fxg-top-title { font-size: 0.85rem; }
}