/* ============================================================
   PlayGame Crash — dark glassmorphism theme (Bootstrap 5 add-on)
   ============================================================ */
:root {
    --pg-bg: #0b0e1a;
    --pg-bg-2: #131730;
    --pg-glass: rgba(255, 255, 255, 0.055);
    --pg-glass-border: rgba(255, 255, 255, 0.09);
    --pg-primary: #7c5cff;
    --pg-primary-2: #4f7cff;
    --pg-green: #2fe08d;
    --pg-red: #ff4d6b;
    --pg-gold: #ffc14d;
    --pg-text: #eef0ff;
    --pg-muted: #9aa2c5;
}

html, body {
    background: radial-gradient(1200px 700px at 80% -10%, rgba(124, 92, 255, .18), transparent 60%),
                radial-gradient(900px 600px at -10% 110%, rgba(47, 224, 141, .10), transparent 60%),
                var(--pg-bg);
    color: var(--pg-text);
    min-height: 100vh;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

.text-muted, .form-text { color: var(--pg-muted) !important; }
a { color: var(--pg-primary-2); }

/* ---- Glass panels ---- */
.glass {
    background: var(--pg-glass);
    border: 1px solid var(--pg-glass-border);
    border-radius: 16px;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 10px 35px rgba(0, 0, 0, .35);
}
.glass-sm { border-radius: 12px; }

.brand-badge {
    background: linear-gradient(135deg, var(--pg-primary), var(--pg-primary-2));
    border-radius: 10px; padding: 4px 10px; font-weight: 800; color: #fff;
}

/* ============================================================
   Player sidebar layout
   ------------------------------------------------------------
   Modes:
   - Push (desktop, non-game pages): sidebar sits beside the
     content; body.sb-user-hidden collapses it (persisted).
   - Overlay (mobile/tablet always, any screen while playing a
     game): sidebar is hidden by default and slides OVER the
     content when body.sb-open is set, with a dimmed backdrop.
   z-order: backdrop 1040 / sidebar 1045 — above the sticky
   topbar (1030), below in-game modals (1050, e.g. slots paytable).
   ============================================================ */
:root { --pg-sb-w: 264px; }

.pg-topbar {
    display: flex; align-items: center; gap: 12px;
    min-height: 64px; padding: 10px 16px;
    background: rgba(11, 14, 26, .8);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--pg-glass-border);
    z-index: 1030;
}
/* On narrow screens the brand yields space to the balance chip / buttons. */
.pg-topbar-brand { flex-shrink: 1; min-width: 0; overflow: hidden; white-space: nowrap; }

.pg-main {
    display: flex; flex-direction: column; min-height: 100vh;
    transition: margin-left .3s cubic-bezier(.4, 0, .2, 1);
}
.pg-main > main { flex: 1 0 auto; }

.pg-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: min(var(--pg-sb-w), 86vw);
    display: flex; flex-direction: column;
    background: rgba(11, 14, 26, .92);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-right: 1px solid var(--pg-glass-border);
    transform: translateX(-100%);
    transition: transform .3s cubic-bezier(.4, 0, .2, 1);
    z-index: 1045;
    overscroll-behavior: contain;
}
.pg-sidebar-head {
    display: flex; align-items: center; min-height: 64px;
    padding: 10px 16px; border-bottom: 1px solid var(--pg-glass-border);
}
.pg-sidebar-nav { flex: 1 1 auto; overflow-y: auto; padding: 12px; scrollbar-width: thin; }
.pg-sidebar-foot { padding: 14px 16px; border-top: 1px solid var(--pg-glass-border); }

.pg-sidebar .sidebar-label {
    color: var(--pg-muted); opacity: .7; font-size: .68rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1px;
    margin: 14px 12px 4px; user-select: none;
}
.pg-sidebar .sidebar-label:first-child { margin-top: 0; }

.pg-nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; margin-bottom: 2px; border-radius: 10px;
    color: var(--pg-muted); font-weight: 500; text-decoration: none;
    transition: background .15s ease, color .15s ease;
}
.pg-nav-link:hover { color: var(--pg-text); background: rgba(255, 255, 255, .05); }
.pg-nav-link.active {
    color: #fff;
    background: linear-gradient(135deg, rgba(124, 92, 255, .30), rgba(79, 124, 255, .16));
    box-shadow: inset 3px 0 0 var(--pg-primary);
}
.pg-nav-ico { width: 1.5em; text-align: center; flex: 0 0 auto; }

.pg-backdrop {
    position: fixed; inset: 0; z-index: 1040;
    background: rgba(3, 5, 12, .55);
    opacity: 0; pointer-events: none;
    transition: opacity .3s ease;
}
body.sb-open .pg-sidebar { transform: none; }
body.sb-open .pg-backdrop { opacity: 1; pointer-events: auto; }

/* Push mode: desktop, outside gameplay */
@media (min-width: 992px) {
    body:not(.game-mode):not(.sb-user-hidden) .pg-sidebar { transform: none; }
    body:not(.game-mode):not(.sb-user-hidden) .pg-main { margin-left: var(--pg-sb-w); }
    /* Brand lives in the sidebar while it is pinned open */
    body:not(.game-mode):not(.sb-user-hidden) .pg-topbar-brand { display: none !important; }
    body:not(.game-mode) .pg-backdrop { display: none; }
}

/* Suppress slide transitions during the initial paint (class removed by JS) */
body.sb-no-anim .pg-sidebar,
body.sb-no-anim .pg-main,
body.sb-no-anim .pg-backdrop { transition: none !important; }

/* Hamburger toggle */
.pg-burger {
    flex: 0 0 auto; width: 42px; height: 42px; padding: 0;
    display: inline-flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 5px;
    background: rgba(255, 255, 255, .05);
    border: 1px solid var(--pg-glass-border); border-radius: 12px;
    transition: background .15s ease, border-color .15s ease;
}
.pg-burger:hover { background: rgba(124, 92, 255, .18); border-color: rgba(124, 92, 255, .45); }
.pg-burger span {
    display: block; width: 18px; height: 2px; border-radius: 2px;
    background: var(--pg-text);
    transition: transform .3s ease, opacity .2s ease;
}
.pg-burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.pg-burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.pg-burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---- Buttons ---- */
.btn-pg {
    background: linear-gradient(135deg, var(--pg-primary), var(--pg-primary-2));
    border: none; color: #fff; font-weight: 700; border-radius: 12px;
    transition: transform .15s ease, box-shadow .15s ease;
}
.btn-pg:hover { color: #fff; transform: translateY(-1px); box-shadow: 0 8px 24px rgba(124, 92, 255, .4); }
.btn-bet {
    background: linear-gradient(135deg, #23d18b, #14b871);
    border: none; color: #04160d; font-weight: 800; border-radius: 14px; font-size: 1.05rem;
}
.btn-bet:hover { color: #04160d; filter: brightness(1.08); }
.btn-cashout {
    background: linear-gradient(135deg, var(--pg-gold), #ff9d3c);
    border: none; color: #221302; font-weight: 800; border-radius: 14px; font-size: 1.05rem;
    animation: pg-pulse 1.2s infinite;
}
.btn-cancel-bet {
    background: linear-gradient(135deg, var(--pg-red), #d93d56);
    border: none; color: #fff; font-weight: 800; border-radius: 14px;
}
@keyframes pg-pulse {
    0%, 100% { box-shadow: 0 0 12px rgba(255, 193, 77, .35); }
    50% { box-shadow: 0 0 28px rgba(255, 193, 77, .7); }
}

/* ---- Forms ---- */
/* Tell the browser this is a dark UI so NATIVE widgets (the <select> options
   popup, date/time pickers, scrollbars) render dark instead of white-on-white. */
:root { color-scheme: dark; }

.form-control, .form-select {
    background: rgba(255, 255, 255, .06);
    border: 1px solid var(--pg-glass-border);
    color: var(--pg-text);
    border-radius: 10px;
}
.form-control:focus, .form-select:focus {
    background: rgba(255, 255, 255, .08); color: var(--pg-text);
    border-color: var(--pg-primary); box-shadow: 0 0 0 .2rem rgba(124, 92, 255, .2);
}
.form-control::placeholder { color: var(--pg-muted); }
.input-group-text { background: rgba(255,255,255,.06); border: 1px solid var(--pg-glass-border); color: var(--pg-muted); }

/* Explicit fallback for browsers that ignore color-scheme on option lists. */
.form-select option, select option {
    background-color: var(--pg-bg-2);
    color: var(--pg-text);
}
.form-select option:disabled { color: var(--pg-muted); }

/* ---- Tables ----
   Bootstrap 5 paints every cell with color: var(--bs-table-color), which
   defaults to the near-black body color (the app doesn't use data-bs-theme).
   A plain `color:` on the table is therefore ignored — the CSS variables
   below are what actually make cell text readable on the dark glass. */
.table-pg {
    --bs-table-bg: transparent;
    --bs-table-color: var(--pg-text);
    --bs-table-striped-color: var(--pg-text);
    --bs-table-active-color: var(--pg-text);
    --bs-table-hover-color: var(--pg-text);
    --bs-table-striped-bg: rgba(255, 255, 255, .03);
    --bs-table-active-bg: rgba(255, 255, 255, .06);
    --bs-table-hover-bg: rgba(255, 255, 255, .05);
    --bs-table-border-color: var(--pg-glass-border);
    color: var(--pg-text);
}
.table-pg th { color: var(--pg-muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .5px; border-color: var(--pg-glass-border); }
.table-pg td { border-color: rgba(255, 255, 255, .05); vertical-align: middle; }

/* ---- Crash history chips ---- */
.crash-chip {
    display: inline-block; padding: 3px 10px; border-radius: 20px;
    font-weight: 700; font-size: .8rem; margin: 2px;
    background: rgba(255, 77, 107, .15); color: var(--pg-red);
}
.crash-chip.win { background: rgba(47, 224, 141, .15); color: var(--pg-green); }
.crash-chip.epic { background: rgba(255, 193, 77, .18); color: var(--pg-gold); }

/* ---- Game area ---- */
.game-stage { position: relative; min-height: 340px; }
#crashCanvas { width: 100%; height: 100%; display: block; border-radius: 16px; }
.multiplier-display {
    position: absolute; inset: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center; pointer-events: none;
}
.multiplier-value {
    font-size: clamp(2.6rem, 8vw, 5rem); font-weight: 900; letter-spacing: -1px;
    color: var(--pg-text); text-shadow: 0 0 30px rgba(124, 92, 255, .5);
    font-variant-numeric: tabular-nums;
}
.multiplier-value.crashed { color: var(--pg-red); text-shadow: 0 0 30px rgba(255, 77, 107, .6); }
.multiplier-sub { color: var(--pg-muted); font-weight: 600; }
.state-note { font-size: .95rem; color: var(--pg-muted); font-weight: 600; }

/* ---- Live feed ---- */
.feed-row { display: flex; justify-content: space-between; font-size: .82rem; padding: 5px 8px; border-radius: 8px; }
.feed-row + .feed-row { margin-top: 2px; }
.feed-row.cashout { background: rgba(47, 224, 141, .08); }
.feed-row.bet { background: rgba(255, 255, 255, .03); }

/* ---- Stat cards ---- */
.stat-card { padding: 18px; }
.stat-card .value { font-size: 1.5rem; font-weight: 800; }
.stat-card .label { color: var(--pg-muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .5px; }

/* ---- Admin sidebar ---- */
.admin-sidebar { min-height: 100vh; background: rgba(11, 14, 26, .85); border-right: 1px solid var(--pg-glass-border); }
.admin-sidebar .nav-link { color: var(--pg-muted); border-radius: 10px; margin-bottom: 2px; }
.admin-sidebar .nav-link.active, .admin-sidebar .nav-link:hover { color: #fff; background: rgba(124, 92, 255, .18); }
.admin-sidebar .sidebar-label {
    color: var(--pg-muted); opacity: .7; font-size: .68rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1px;
    margin: 14px 12px 4px; user-select: none;
}
.admin-sidebar .sidebar-label:first-child { margin-top: 0; }
/* Off-canvas variant (mobile/tablet drawer) inherits the same look */
.offcanvas.admin-sidebar { min-height: auto; border-right: 1px solid var(--pg-glass-border); }

/* ---- Misc ---- */
.badge-state { font-size: .72rem; letter-spacing: .5px; text-transform: uppercase; }
.text-green { color: var(--pg-green) !important; }
.text-red { color: var(--pg-red) !important; }
.text-gold { color: var(--pg-gold) !important; }
.pagination { --bs-pagination-bg: transparent; --bs-pagination-color: var(--pg-muted); --bs-pagination-border-color: var(--pg-glass-border); }
.pagination .page-item.active .page-link { background: var(--pg-primary); border-color: var(--pg-primary); }
.alert-pg { background: rgba(124, 92, 255, .12); border: 1px solid rgba(124, 92, 255, .3); color: var(--pg-text); border-radius: 12px; }


/* ============================================================
   In-game LIVE players indicator
   ------------------------------------------------------------
   Lives at the right-hand end of the sticky topbar rather than
   floating over the play area: a fixed overlay at top-right
   covered the crash game's Auto button and wallet selector.
   The topbar is already the reserved chrome lane, so nothing
   collides and it stays put while the game scrolls.
   ============================================================ */
.pg-live {
    display: flex; flex-direction: column; align-items: center;
    flex-shrink: 0; gap: 2px;
    padding: 4px 11px 5px;
    background: rgba(255, 255, 255, .045);
    border: 1px solid var(--pg-glass-border);
    border-radius: 11px;
    line-height: 1; white-space: nowrap; user-select: none;
}

.pg-live-top { display: flex; align-items: center; gap: 4px; }

.pg-live-dot {
    width: 5px; height: 5px; border-radius: 50%;
    background: var(--pg-red); flex-shrink: 0;
    animation: pg-live-pulse 2.4s ease-out infinite;
}
@keyframes pg-live-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(255, 77, 107, .55); }
    70%  { box-shadow: 0 0 0 6px rgba(255, 77, 107, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 77, 107, 0); }
}

.pg-live-word {
    font-size: .55rem; font-weight: 800; line-height: 1;
    letter-spacing: .13em; text-transform: uppercase; color: var(--pg-red);
}

.pg-live-count {
    font-size: .84rem; font-weight: 800; line-height: 1.1;
    letter-spacing: -.02em; color: var(--pg-text);
    font-variant-numeric: tabular-nums; /* digits keep their column on change */
}

/* Transform only, never opacity: if the animation clock is stalled (throttled
   or backgrounded tab) a frozen 0% keyframe must still leave the figure fully
   readable rather than faded out. */
.pg-live-count.is-updating { animation: pg-live-bump .7s cubic-bezier(.4, 0, .2, 1); }
@keyframes pg-live-bump {
    0%, 100% { transform: none; }
    35%      { transform: translateY(-3px); }
}

/* Narrow phones: the topbar is tight, so trim the padding rather than let the
   indicator push the balance chip off the row. */
@media (max-width: 419.98px) {
    .pg-live { padding: 3px 8px 4px; border-radius: 9px; }
    .pg-live-count { font-size: .78rem; }
    .pg-live-word { font-size: .5rem; letter-spacing: .1em; }
}

@media (prefers-reduced-motion: reduce) {
    .pg-live-dot, .pg-live-count.is-updating { animation: none; }
}
