/* ==========================================================================
   CrashMax — App Shell Styles
   --------------------------------------------------------------------------
   Mobile-first. 90% of traffic is on mobile so the cascade is built that
   way: phone-sized rules are the default, the `@media (min-width: 960px)`
   block layers desktop on top. A third mode `body.mini` strips chrome for
   embedded / launcher contexts (?mini=true).

   Aesthetic: dark cyberpunk-arcade. Deep void background, subtle scan-line
   texture, tier-colored multiplier (white → cyan → amber → magenta), a
   breathing cashout button, italic display numerals for motion.

   Architecture
     - Design tokens in :root, theme-overridable via body.theme-X { … }
     - CSS Grid for the app shell, Flexbox/Grid mix inside components
     - Mobile uses a tab between BET 1 / BET 2 (body[data-active-bet=0|1])
       to avoid the desktop side-by-side stack that was too tall on phones
   ========================================================================== */


/* ==========================================================================
   1. DESIGN TOKENS
   ========================================================================== */
:root {
    /* ---- Color: Surfaces ----
       Neutral charcoal, layered near-black → grey so the orange brand
       accent reads hot against it. Depth without per-element shadow. */
    --color-bg:           #14161a;    /* page bg — soft dark grey         */
    --color-surface:      #1b1e24;    /* main panels (lifted)             */
    --color-surface-2:    #242832;    /* nested rows, inputs              */
    --color-surface-3:    #2f343f;    /* hover / active states           */
    --color-border:       #363b46;    /* hairline separators             */
    --color-border-soft:  #262a32;    /* subtler separator               */

    /* ---- Color: Text ---- */
    --color-text:         #f5f7fa;
    --color-text-muted:   #9aa3b2;
    --color-text-dim:     #626a78;

    /* ---- Color: Brand & State ----
       One hot accent — accamax orange. Wins stay emerald, crashes red. */
    --color-primary:        #f97316;   /* orange-500 — the highlight        */
    --color-primary-hover:  #fb8c3c;
    --color-primary-glow:   rgba(249, 115, 22, 0.45);
    --color-primary-deep:   #ea580c;   /* accamax orange-600 — pressed/edge */
    --color-success:        #10b981;   /* emerald — wins, cashout           */
    --color-success-glow:   rgba(16, 185, 129, 0.40);
    --color-danger:         #ef4444;   /* red — crash                       */
    --color-danger-glow:    rgba(239, 68, 68, 0.42);
    --color-warning:        #f59e0b;   /* amber                             */
    /* Legacy accent slots, retuned onto the orange ramp so any stray
       reference stays on-theme. */
    --color-cyan:           #f59e0b;
    --color-magenta:        #ff6b35;

    /* Multiplier-tier colors — a "heating up" ramp (white → amber → orange
       → hot orange-red), set on .round-overlay via data-tier by
       round-overlay.ts. Distinct from the pure crash red. */
    --tier-1:  var(--color-text);     /* 1.00 — 2.00x   white       */
    --tier-2:  var(--color-warning);  /* 2.00 — 5.00x   amber       */
    --tier-3:  var(--color-primary);  /* 5.00 — 10.0x   orange      */
    --tier-4:  #ff6b35;               /* 10.0x+         hot orange  */

    /* ---- Spacing scale ---- */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;

    /* ---- Radii ---- */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-pill: 999px;

    /* ---- Typography ----
       Bricolage Grotesque — distinctive display face with expressive italic;
       used italic on the multiplier so the number itself feels in motion.
       Manrope — characterful sans for UI body text.
       JetBrains Mono — tabular monospace for numeric readouts that need
       column alignment (balance, stake, multiplier history). */
    --font-display: 'Bricolage Grotesque', 'Manrope', system-ui, sans-serif;
    --font-body:    'Manrope', system-ui, -apple-system, sans-serif;
    --font-mono:    'JetBrains Mono', ui-monospace, 'SFMono-Regular', monospace;

    /* ---- Elevation ---- */
    --shadow-inset:  inset 0 1px 0 rgba(255,255,255,0.04);
    --shadow-card:   0 8px 24px -8px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255,255,255,0.04);
    --shadow-cta:    0 12px 32px -10px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.1);

    /* ---- Layout ---- */
    --header-height-mobile:  60px;
    --header-height-desktop: 68px;
    --max-width:             1480px;
}


/* ==========================================================================
   2. RESET / BASE
   ========================================================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

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

body {
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.4;
    color: var(--color-text);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    min-height: 100dvh;
    overscroll-behavior-y: none;
    -webkit-tap-highlight-color: transparent;
}

/* Atmospheric backdrop — sits behind everything. Soft radial glows in
   brand colors, plus a faint scan-line pattern that catches light only
   when content is sparse. Adds depth on the otherwise flat dark bg. */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(60vw 50vh at 50% 24%, rgba(249, 115, 22, 0.10), transparent 60%),
        radial-gradient(50vw 50vh at 100% 100%, rgba(234, 88, 12, 0.06), transparent 60%),
        radial-gradient(50vw 50vh at 0% 90%, rgba(245, 158, 11, 0.05), transparent 60%);
    pointer-events: none;
    z-index: -2;
}
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background-image: repeating-linear-gradient(
        0deg,
        rgba(255, 255, 255, 0.015) 0 1px,
        transparent 1px 3px
    );
    pointer-events: none;
    z-index: -1;
    opacity: 0.6;
}

button {
    font-family: inherit;
    color: inherit;
    border: none;
    background: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

input {
    font-family: inherit;
    color: inherit;
}

ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

h1, h2, h3 {
    margin: 0;
}


/* ==========================================================================
   3. APP SHELL — mobile-first grid
   --------------------------------------------------------------------------
   Mobile rows:
       header           (52px)
       history strip    (auto)
       canvas / main    (1fr — fills)
       bet panel        (auto, pinned-bottom feel)

   Desktop adds a sidebar column for participants/chat — see (10).
   ========================================================================== */
.app-shell {
    display: grid;
    grid-template-rows: var(--header-height-mobile) auto 1fr auto;
    grid-template-areas:
        "header"
        "history"
        "main"
        "betpanel";
    min-height: 100vh;
    min-height: 100dvh;
    max-width: var(--max-width);
    margin: 0 auto;
}


/* ==========================================================================
   4. HEADER — compact on mobile, fuller on desktop
   ========================================================================== */
.app-header {
    grid-area: header;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height-mobile);
    padding: 0 var(--space-3);
    border-bottom: 1px solid var(--color-border-soft);
    background: var(--color-surface-2);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
    overflow: hidden;
}

.brand__logo {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
}
.brand__logo-img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    display: block;
}
.brand__logo-img.is-hidden,
#brand-logo-fallback.is-hidden { display: none; }

.brand__name {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--color-text);
    /* white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; */
}
.brand__name::after {
    /* Subtle brand accent dot next to the name. */
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--color-primary);
    border-radius: 50%;
    margin-left: 6px;
    box-shadow: 0 0 8px var(--color-primary-glow);
    vertical-align: 2px;
}

.header__right {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}

/* Wallet — pill, compact on mobile */
.wallet {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    background: linear-gradient(180deg, var(--color-surface-2), var(--color-surface));
    border: 1px solid var(--color-border);
    padding: 8px 14px;
    border-radius: var(--radius-pill);
}
.wallet__label {
    display: none;        /* desktop reveals it */
    font-size: 10px;
    color: var(--color-text-dim);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
}
.wallet__amount {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    color: var(--color-text);
    white-space: nowrap;
}

/* Online-count + connection indicator — hidden by default on mobile,
   shown on desktop. Keep them in the DOM so JS handlers still work. */
.online-count,
.conn-indicator {
    display: none;
}

/* ==========================================================================
   5. HISTORY STRIP — micro pills, horizontal scroll
   ========================================================================== */
.history-strip {
    grid-area: history;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}
.history-strip::-webkit-scrollbar { display: none; }
.history-strip:empty { display: none; }

.history__pill {
    flex: 0 0 auto;
    height: 24px;
    min-width: 48px;
    padding: 0 10px;
    border-radius: var(--radius-pill);
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.12s ease, border-color 0.15s ease;
    cursor: pointer;
}
.history__pill:hover { transform: translateY(-1px); }
.history__pill:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}
/* Pre-deploy rounds without seeds — not clickable, no hover affordance. */
.history__pill--unverifiable {
    cursor: default;
    opacity: 0.55;
}
.history__pill--unverifiable:hover { transform: none; }

/* Tier coloring — set by history.ts via class.
   Low (<2x):   subdued, slightly red.
   Mid (2-5x):  cyan tint — "decent" win.
   High (5-10x): orange — "good" win.
   Mega (10+x): hot orange gradient — "memorable" win. */
.history__pill--low  { color: #fca5a5; border-color: rgba(239, 68, 68, 0.25); }
.history__pill--mid  { color: var(--color-warning); border-color: rgba(245, 158, 11, 0.3); background: rgba(245, 158, 11, 0.06); }
.history__pill--high { color: var(--color-primary); border-color: rgba(249, 115, 22, 0.4); background: rgba(249, 115, 22, 0.07); }
.history__pill--mega {
    color: #fff;
    border-color: transparent;
    background: linear-gradient(135deg, var(--color-primary), #ff6b35);
    box-shadow: 0 0 14px rgba(249, 115, 22, 0.4);
}


/* ==========================================================================
   6. MAIN — game canvas area
   ========================================================================== */
.app-main {
    grid-area: main;
    position: relative;
    display: flex;
    min-width: 0;
    min-height: 0;
    padding: 4px 12px 8px;
}

.game-column {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    min-height: 0;       /* allow children to shrink below content */
    position: relative;  /* positioning context for .connection-lost (a sibling of
                            #game-canvas-container, so the game's innerHTML wipe can't
                            destroy it — see index.html) */
}

/* The game canvas container — fixed aspect-ratio (16:9) at every
   breakpoint. The container is the SHELL'S responsibility; it's the
   GAME'S responsibility to letterbox / scale its content inside this
   box if its native ratio differs.

   Why fixed (not dynamic):
     - Predictable layout that can't shrink to a line if the canvas's
       intrinsic dimensions are weird or arrive late.
     - No layout feedback loops between game's ResizeObserver and our
       sizing math.
     - The flex track no longer needs `flex-basis: 0`; aspect-ratio
       drives a deterministic height from the 100% width.

   `contain: size layout paint` still isolates inner resize observers
   so the game can't perturb outer layout regardless of what it does. */
.game-canvas-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    flex: 0 0 auto;
    max-height: 100%;
    contain: size layout paint;
    background:
        radial-gradient(140% 100% at 50% 100%, rgba(245, 158, 11, 0.06), transparent 50%),
        radial-gradient(80% 60% at 50% 0%, rgba(255, 107, 53, 0.04), transparent 60%),
        var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

/* Light grid pattern visible until the game UMD mounts */
.game-canvas-container::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
    background-size: 32px 32px;
    pointer-events: none;
    mask-image: radial-gradient(80% 80% at 50% 50%, #000 40%, transparent 100%);
    -webkit-mask-image: radial-gradient(80% 80% at 50% 50%, #000 40%, transparent 100%);
}


/* ---------- Game loader overlay ---------- */
.game-loader {
    position: absolute;
    inset: 0;
    z-index: 7;   /* above the mounted game canvas; below connection-lost (8) */
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(50% 50% at 50% 50%, rgba(249, 115, 22, 0.14), transparent 70%),
        var(--color-surface);
    transition: opacity 0.4s ease, visibility 0.4s ease;
}
.game-loader.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* ---- While the game module loads, lock the whole shell ----
   Every button / input / tab is disabled until the game is ready (or the
   load fails). The test harness is exempt so devs can still drive it. */
body.game-loading { cursor: progress; }
body.game-loading button,
body.game-loading input,
body.game-loading select,
body.game-loading textarea,
body.game-loading [role="tab"],
body.game-loading [role="button"] {
    pointer-events: none;
    opacity: 0.55;
}
body.game-loading .th-root,
body.game-loading .th-root button,
body.game-loading .th-root input,
body.game-loading .th-root select,
body.game-loading .th-root textarea,
body.game-loading .th-root [role="tab"],
body.game-loading .th-root [role="button"] {
    pointer-events: auto;
    opacity: 1;
}

/* Connection-lost cover — opaque, pinned to .game-column (its positioned
   ancestor) so it covers the whole canvas area AND any mounted game canvas,
   keeping the stale multiplier hidden while the game hub is down. It is a
   SIBLING of #game-canvas-container (not a child) so the game module's
   innerHTML wipe on mount can't destroy it. */
.connection-lost {
    position: absolute;
    inset: 0;
    z-index: 8;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background:
        radial-gradient(50% 50% at 50% 50%, rgba(239, 68, 68, 0.10), transparent 70%),
        var(--color-bg);
}
.connection-lost.is-hidden { display: none; }
.connection-lost__inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-5);
}
.connection-lost__spinner {
    width: 30px;
    height: 30px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-danger);
    border-radius: 50%;
    animation: connection-lost-spin 0.8s linear infinite;
}
@keyframes connection-lost-spin { to { transform: rotate(360deg); } }
.connection-lost__title {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 800;
    color: var(--color-danger);
}
.connection-lost__sub {
    font-size: 13px;
    color: var(--color-text-muted);
}
@media (prefers-reduced-motion: reduce) {
    .connection-lost__spinner { animation: none; }
}
.game-loader__wrap {
    width: min(320px, 80%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
}
.game-loader__logo {
    max-width: 140px;
    height: auto;
    margin-bottom: var(--space-2);
    filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.5));
    opacity: 1;
    transition: opacity 0.35s ease;
}
/* Held hidden by asset-loader until the image has fully downloaded. */
.game-loader__logo.is-pending { opacity: 0; }
.game-loader__bar {
    width: 100%;
    height: 4px;
    background: var(--color-surface-2);
    border-radius: var(--radius-pill);
    overflow: hidden;
}
.game-loader__fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--color-primary), #ff6b35);
    box-shadow: 0 0 12px var(--color-primary-glow);
    transition: width 0.2s ease-out;
}
.game-loader__percent {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.1em;
}
.game-loader__error {
    /* Bottom banner instead of full-canvas takeover — the shell's own
       multiplier overlay stays visible and useful even when the game
       UMD failed to load (e.g. no gameid in URL, R2 path 404). */
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 3;
    padding: 8px 12px;
    color: var(--color-danger);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    background: rgba(8, 9, 15, 0.7);
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-radius: var(--radius-md);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* ==========================================================================
   7. ROUND OVERLAYS — state badge + huge multiplier
   ========================================================================== */
.round-status {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px 5px 8px;
    background: rgba(8, 9, 15, 0.75);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
    color: var(--color-text);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.12em;
    pointer-events: none;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.round-status__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--color-text-muted);
    box-shadow: 0 0 8px currentColor;
}
.round-status[data-state="waiting"]  .round-status__dot { background: var(--color-warning); color: var(--color-warning); animation: round-status-pulse 1.2s ease-in-out infinite; }
.round-status[data-state="in-play"]  .round-status__dot { background: var(--color-success); color: var(--color-success); animation: round-status-pulse 0.9s ease-in-out infinite; }
.round-status[data-state="crashed"]  .round-status__dot { background: var(--color-danger); color: var(--color-danger); }
.round-status[data-state="waiting"]  { border-color: rgba(251, 191, 36, 0.3); }
.round-status[data-state="in-play"]  { border-color: rgba(16, 185, 129, 0.3); }
.round-status[data-state="crashed"]  { border-color: rgba(239, 68, 68, 0.4); }

@keyframes round-status-pulse {
    0%, 100% { opacity: 0.65; transform: scale(1);    }
    50%      { opacity: 1;    transform: scale(1.35); }
}

/* The big multiplier — italic display font, tier-colored, dominates
   the canvas area. Sized to feel weighty on mobile (smaller viewport)
   but not overwhelm the canvas — clamp scales it gracefully. */
.round-overlay {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    pointer-events: none;
    text-align: center;
    user-select: none;
}

.round-overlay__big {
    font-family: var(--font-display);
    font-style: italic;
    font-size: clamp(64px, 18vw, 168px);
    font-weight: 800;
    line-height: 1;
    color: var(--tier-1);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.04em;
    text-shadow: 0 6px 40px rgba(0, 0, 0, 0.7);
    transition: color 0.3s ease, text-shadow 0.3s ease;
}
.round-overlay[data-tier="2"] .round-overlay__big { color: var(--tier-2); text-shadow: 0 0 40px rgba(245, 158, 11, 0.35), 0 6px 20px rgba(0, 0, 0, 0.6); }
.round-overlay[data-tier="3"] .round-overlay__big { color: var(--tier-3); text-shadow: 0 0 50px rgba(251, 191, 36, 0.4),  0 6px 20px rgba(0, 0, 0, 0.6); }
.round-overlay[data-tier="4"] .round-overlay__big { color: var(--tier-4); text-shadow: 0 0 60px rgba(255, 107, 53, 0.5),  0 6px 20px rgba(0, 0, 0, 0.6); }

.round-status[data-state="crashed"] ~ .round-overlay .round-overlay__big {
    color: var(--color-danger);
    text-shadow: 0 0 60px rgba(239, 68, 68, 0.5), 0 6px 20px rgba(0, 0, 0, 0.6);
    animation: crash-shake 0.45s ease-out;
}
@keyframes crash-shake {
    0%   { transform: translateX(0); }
    15%  { transform: translateX(-6px) rotate(-1deg); }
    30%  { transform: translateX(5px)  rotate(1deg);  }
    45%  { transform: translateX(-4px); }
    60%  { transform: translateX(3px);  }
    75%  { transform: translateX(-2px); }
    100% { transform: translateX(0); }
}

.round-overlay__sub {
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 700;
    color: var(--color-text-muted);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
}

/* Auto-hide shell overlay once the game module mounts */
body.game-mounted .round-status,
body.game-mounted .round-overlay {
    display: none;
}

.game-column {
    justify-content: center;       /* center the fixed-aspect container in leftover row space */
}

/* Defer-fade-in so the overlay doesn't flash on game-mount races */
.round-status,
.round-overlay {
    opacity: 0;
    animation: shell-overlay-defer-fade-in 0.3s ease-out 0.5s forwards;
}
@keyframes shell-overlay-defer-fade-in {
    to { opacity: 1; }
}


/* ==========================================================================
   8. BET PANEL AREA — pinned at the bottom on mobile
   --------------------------------------------------------------------------
   On mobile the two .bet-panel articles are siblings inside .bet-row.
   We show ONE at a time, selected by body[data-active-bet="0|1"].
   .bet-tabs is the visible toggle between them.

   On desktop both panels show side-by-side and .bet-tabs is hidden.
   ========================================================================== */
.bet-row {
    grid-area: betpanel;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    background: linear-gradient(180deg, transparent 0%, rgba(8, 9, 15, 0.4) 18%, var(--color-surface) 50%);
    padding: 8px 12px;
    padding-bottom: calc(60px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--color-border-soft);
}

/* Bet panel tab strip — hidden by default, landscape restores it */
.bet-tabs {
    display: none;
    gap: 2px;
    padding: 3px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 11px;
    margin-bottom: 8px;
}
.bet-tabs__tab {
    flex: 1;
    padding: 8px 4px;
    border-radius: 8px;
    background: transparent;
    color: var(--color-text-muted);
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.15s ease, color 0.15s ease;
}
.bet-tabs__tab[data-active] {
    background: var(--color-surface-2);
    color: var(--color-text);
    box-shadow: var(--shadow-inset);
}
.bet-tabs__tab[data-state="queued"]  .bet-tabs__dot { background: var(--color-warning); }
.bet-tabs__tab[data-state="active"]  .bet-tabs__dot { background: var(--color-success); animation: round-status-pulse 0.9s infinite; }
.bet-tabs__tab[data-state="cashed"]  .bet-tabs__dot { background: var(--color-success); }
.bet-tabs__tab[data-state="busted"]  .bet-tabs__dot { background: var(--color-danger); }
.bet-tabs__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: transparent;
    flex: 0 0 auto;
    transition: background 0.2s ease;
}

/* ---------- BetPanel ---------- */
.bet-panel {
    display: grid;
    gap: 8px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 10px;
}

/* Both panels always visible — tab switching is only used in
   landscape mobile where the right column is too narrow for two. */
body[data-active-bet] .bet-row .bet-panel {
    display: grid !important;
}

/* ---------- Stake input ---------- */
.stake { display: contents; }     /* let children flow into the panel grid */
.stake__label { display: none; }   /* mobile hides the label — input is self-evident */

.stake__input-wrap {
    display: flex;
    align-items: stretch;
    gap: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    height: 44px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.stake__input-wrap:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-glow);
}

.stake__currency {
    padding: 0 8px 0 2px;
    display: inline-flex;
    align-items: center;
    color: var(--color-text-muted);
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 13px;
}
.stake__input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    outline: none;
    font-family: var(--font-mono);
    font-size: 16px;          /* 16px on mobile suppresses iOS auto-zoom */
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    padding: 0;
    color: var(--color-text);
}
.stake__steppers {
    display: flex;
    gap: 1px;
    background: var(--color-border);
}
.stepper {
    width: 38px;
    background: var(--color-surface);
    color: var(--color-text);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 20px;
    line-height: 1;
    display: grid;
    place-items: center;
    transition: background 0.15s ease, color 0.15s ease;
}
.stepper:hover { background: var(--color-surface-2); color: var(--color-primary); }
.stepper:active { background: var(--color-surface-3); }

/* ---------- Quick-stake pills ---------- */
.quick-stakes {
    display: none;
}
.pill {
    height: 30px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    border-radius: var(--radius-pill);
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}
.pill:hover { background: var(--color-surface-2); border-color: var(--color-primary); }
.pill:active { transform: scale(0.96); }

/* ---------- Auto controls — hidden on portrait mobile (two panels
   side-by-side leaves ~175px each, too narrow for toggle+cashout).
   Restored in landscape and desktop. ---------- */
.bet-actions {
    display: none;
}

.toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--color-text-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
}
.toggle input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.toggle__track {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 18px;
    background: var(--color-surface-3);
    border-radius: var(--radius-pill);
    transition: background 0.2s ease;
    flex-shrink: 0;
}
.toggle__thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: var(--color-text);
    border-radius: 50%;
    transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}
.toggle input:checked ~ .toggle__track { background: var(--color-primary); }
.toggle input:checked ~ .toggle__track .toggle__thumb { transform: translateX(14px); }
.toggle__label {
    color: var(--color-text-muted);
    transition: color 0.15s ease;
}
.toggle input:checked ~ .toggle__label { color: var(--color-text); }

.auto-cashout {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 4px 8px;
    height: 32px;
    transition: border-color 0.15s ease;
}
.auto-cashout:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-primary-glow);
}
.auto-cashout__label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-text-dim);
    font-weight: 700;
    white-space: nowrap;
}
.auto-cashout__input-wrap {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    justify-content: flex-end;
}
.auto-cashout__input {
    width: 50px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--color-text);
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: right;
}
.auto-cashout__input:disabled { color: var(--color-text-dim); }
.auto-cashout__input::placeholder { color: var(--color-text-dim); }
.auto-cashout__suffix {
    color: var(--color-text-dim);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
}

/* ---------- PLACE BET / CASHOUT — full-width primary ---------- */
.place-bet {
    width: 100%;
    min-height: 56px;
    border-radius: 14px;
    touch-action: manipulation;   /* no tap-delay / double-tap zoom — instant multi-touch response */
    background: linear-gradient(180deg, var(--color-primary), var(--color-primary-deep));
    color: #fff;
    font-family: var(--font-body);
    font-weight: 800;
    letter-spacing: 0.04em;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    box-shadow: var(--shadow-cta), 0 0 20px var(--color-primary-glow);
    transition: transform 0.1s ease, opacity 0.2s ease, box-shadow 0.25s ease, background 0.2s ease;
    position: relative;
    overflow: hidden;
}
.place-bet::after {
    /* Subtle inner top-edge highlight */
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
}
.place-bet:disabled {
    opacity: 0.4;
    box-shadow: none;
    cursor: not-allowed;
}
.place-bet:active:not(:disabled) { transform: scale(0.98); }
.place-bet__title {
    font-size: 14px;
    line-height: 1.1;
}
.place-bet__amount {
    font-family: var(--font-mono);
    font-size: 16px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    opacity: 0.85;
}

/* State variants */
.place-bet--cancel {
    background: linear-gradient(180deg, #f87171, #dc2626);
    box-shadow: var(--shadow-cta), 0 0 20px var(--color-danger-glow);
}
.place-bet--cashout {
    background: linear-gradient(180deg, var(--color-success), #0e9f6e);
    box-shadow: var(--shadow-cta), 0 0 24px var(--color-success-glow);
    animation: cashout-breathe 1.4s ease-in-out infinite;
}
@keyframes cashout-breathe {
    0%, 100% { box-shadow: var(--shadow-cta), 0 0 24px var(--color-success-glow); transform: scale(1); }
    50%      { box-shadow: var(--shadow-cta), 0 0 38px rgba(16, 185, 129, 0.65); transform: scale(1.01); }
}
.place-bet--cashed {
    background: linear-gradient(180deg, var(--color-surface-3), var(--color-surface-2));
    color: var(--color-success);
    box-shadow: var(--shadow-cta);
    animation: none;
}
.place-bet--busted {
    background: linear-gradient(180deg, var(--color-surface-3), var(--color-surface-2));
    color: var(--color-danger);
    opacity: 0.7;
    box-shadow: var(--shadow-cta);
    animation: none;
}

/* ---------- Auto toggles row (portrait mobile) ---------- */
.auto-toggles {
    display: grid;
    gap: 6px;
}

/* Shared toggle base — autoplay + cashout */
.autoplay-tog,
.cashout-tog {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-muted);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    transition: border-color 0.15s ease;
}
.autoplay-tog:active,
.cashout-tog:active { transform: scale(0.98); }

.autoplay-tog[aria-pressed="true"] {
    border-color: var(--color-primary);
    color: var(--color-text);
}
.cashout-tog[aria-pressed="true"] {
    border-color: var(--color-success);
    color: var(--color-text);
}
/* Odds suffix on the toggle label — opt out of the button's uppercasing
   so the multiplier reads "(2.00x)" with a lowercase x. */
.cashout-tog__odds { text-transform: none; }

/* Long label by default; the short "Cashout" form is only shown in the narrow
   landscape layout (where the two toggles sit side-by-side). */
.cashout-tog__name--short { display: none; }

/* Locked while a bet is placed — auto cashout can only be toggled when idle. */
.cashout-tog:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.cashout-tog:disabled:active { transform: none; }

/* Shared indicator track */
.autoplay-tog__indicator,
.cashout-tog__indicator {
    width: 28px;
    height: 16px;
    background: var(--color-surface-3);
    border-radius: var(--radius-pill);
    position: relative;
    transition: background 0.2s ease;
    flex-shrink: 0;
}
.autoplay-tog__indicator::after,
.cashout-tog__indicator::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 12px;
    height: 12px;
    background: var(--color-text);
    border-radius: 50%;
    transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}
.autoplay-tog[aria-pressed="true"] .autoplay-tog__indicator {
    background: var(--color-primary);
}
.cashout-tog[aria-pressed="true"] .cashout-tog__indicator {
    background: var(--color-success);
}
.autoplay-tog[aria-pressed="true"] .autoplay-tog__indicator::after,
.cashout-tog[aria-pressed="true"] .cashout-tog__indicator::after {
    transform: translateX(12px);
}

/* ---------- Cashout editor overlay ---------- */
.cashout-editor {
    display: grid;
    gap: 10px;
    padding: 10px;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}
.cashout-editor[hidden] { display: none; }

.cashout-editor__title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    text-align: center;
}
.cashout-editor__input-row {
    display: flex;
    align-items: stretch;
    gap: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    height: 40px;
}
.cashout-editor__input-row .stepper {
    width: 36px;
    flex-shrink: 0;
}
.cashout-editor__input-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 0;
}
.cashout-editor__input {
    width: 60px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--color-text);
    font-family: var(--font-mono);
    font-size: 16px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: center;
}
.cashout-editor__suffix {
    color: var(--color-text-muted);
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
}
.cashout-editor__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}
.cashout-editor__cancel,
.cashout-editor__confirm {
    padding: 8px 4px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.cashout-editor__cancel {
    background: var(--color-surface-3);
    color: var(--color-text-muted);
}
.cashout-editor__cancel:active { background: var(--color-surface); }
.cashout-editor__confirm {
    background: var(--color-success);
    color: #0a0b0e;
}
.cashout-editor__confirm:active { opacity: 0.85; }

/* When cashout editor is open, hide stake + bet button + toggles */
.bet-panel[data-view="cashout"] .stake,
.bet-panel[data-view="cashout"] .place-bet,
.bet-panel[data-view="cashout"] .auto-toggles {
    display: none !important;
}

/* ---------- Autoplay editor overlay ---------- */
.autoplay-editor {
    display: grid;
    gap: 6px;
    padding: 10px;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}
.autoplay-editor[hidden] { display: none; }
.autoplay-editor__title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    text-align: center;
}
.autoplay-editor__label {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted);
}
.autoplay-editor__input-row {
    display: flex;
    gap: 0;
    height: 40px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.autoplay-editor__step {
    width: 36px;
    flex-shrink: 0;
}
.autoplay-editor__input-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 0;
}
.autoplay-editor__input {
    width: 40px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--color-text);
    font-family: var(--font-mono);
    font-size: 16px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: center;
}
.autoplay-editor__suffix {
    color: var(--color-text-muted);
    font-size: 11px;
    font-weight: 600;
}
.autoplay-editor__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}
.autoplay-editor__cancel,
.autoplay-editor__confirm {
    padding: 8px 4px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.autoplay-editor__cancel {
    background: var(--color-surface-3);
    color: var(--color-text-muted);
}
.autoplay-editor__cancel:active { background: var(--color-surface); }
.autoplay-editor__confirm {
    background: var(--color-primary);
    color: #0a0b0e;
}
.autoplay-editor__confirm:active { opacity: 0.85; }

/* When autoplay editor is open, hide stake + bet button + toggles */
.bet-panel[data-view="autoplay"] .stake,
.bet-panel[data-view="autoplay"] .place-bet,
.bet-panel[data-view="autoplay"] .auto-toggles {
    display: none !important;
}


/* ==========================================================================
   9. SIDEBAR (Participants / Chat) — bottom sheet on mobile
   --------------------------------------------------------------------------
   Mobile: hidden by default, slides up as a bottom sheet when the
   floating-action-button (.sidebar-fab) is tapped.
   Desktop: becomes a static right column.
   ========================================================================== */
.sidebar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 50;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -20px 50px -10px rgba(0, 0, 0, 0.6);
    transform: translateY(100%);
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
    max-height: 72dvh;
    display: flex;
    flex-direction: column;
    min-height: 0;   /* respect bounded height (grid track / max-height) so inner panels scroll */
}
.sidebar[data-open="true"] { transform: translateY(0); }

.sidebar__handle {
    align-self: center;
    width: 36px;
    height: 4px;
    background: var(--color-surface-3);
    border-radius: 999px;
    margin: 8px 0;
    flex: 0 0 auto;
}

.sidebar__tabs {
    display: flex;
    flex: 0 0 auto;
    border-bottom: 1px solid var(--color-border-soft);
}
.sidebar__tab {
    flex: 1;
    background: transparent;
    border: 0;
    padding: 12px 8px 14px;
    color: var(--color-text-muted);
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    position: relative;
    transition: color 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.sidebar__tab[aria-selected="true"],
.sidebar__tab--active { color: var(--color-text); }
.sidebar__tab[aria-selected="true"]::after,
.sidebar__tab--active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 28%;
    right: 28%;
    height: 2px;
    background: var(--color-primary);
    border-radius: 2px;
}
.sidebar__tab-count {
    background: var(--color-surface-3);
    color: var(--color-text-muted);
    padding: 1px 6px;
    border-radius: var(--radius-pill);
    font-size: 10px;
    font-variant-numeric: tabular-nums;
}

/* Floating action button (mobile only) — opens the sidebar */
.sidebar-fab {
    position: fixed;
    right: 12px;
    bottom: calc(310px + env(safe-area-inset-bottom));    /* sits above the bet panel */
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    z-index: 40;
    box-shadow: var(--shadow-cta);
    display: grid;
    place-items: center;
    transition: transform 0.15s ease;
}
.sidebar-fab[hidden] { display: none; }
.sidebar-fab:active { transform: scale(0.94); }
.sidebar-fab svg { width: 20px; height: 20px; display: block; }
.sidebar-fab__badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    background: var(--color-danger);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.sidebar-fab[data-open="true"] { background: var(--color-primary); border-color: var(--color-primary); }

/* ---------- Bottom tab bar (portrait mobile only) ---------- */
.bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 40;
    display: flex;
    align-items: stretch;
    height: calc(48px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
}
.bottom-bar[hidden] { display: none; }

.bottom-bar__tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 4px 0;
    color: var(--color-text-dim);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    transition: color 0.15s ease;
}
.bottom-bar__tab svg {
    width: 20px;
    height: 20px;
    display: block;
}
.bottom-bar__tab[data-active] {
    color: var(--color-primary);
}

/* Backdrop dimming the rest of the screen when sidebar is open */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 49;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.sidebar-backdrop[data-open="true"] {
    opacity: 1;
    pointer-events: auto;
}

/* Participants list */
.participants {
    flex: 1 1 auto;
    min-height: 0;   /* allow shrink below content so overflow-y scrolls */
    overflow-y: auto;
    padding: 0 12px 12px;
}
.participants__cols {
    display: grid;
    grid-template-columns: 1.6fr 0.7fr 0.7fr 0.9fr;
    padding: 8px 8px;
    color: var(--color-text-dim);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-bottom: 1px solid var(--color-border-soft);
}
.col--bet, .col--mult, .col--payout { text-align: right; }
.participants__list { padding: 4px 0; }
.player {
    display: grid;
    grid-template-columns: 1.6fr 0.7fr 0.7fr 0.9fr;
    align-items: center;
    padding: 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    transition: background 0.15s ease;
}
.player:hover { background: var(--color-surface-2); }
.player--cashed { background: rgba(16, 185, 129, 0.05); }
.player__user {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.player__name {
    color: var(--color-text);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--avatar-bg, var(--color-primary));
    display: inline-grid;
    place-items: center;
    color: #fff;
    font-weight: 700;
    font-size: 10px;
    flex-shrink: 0;
}
.player__bet,
.player__mult,
.player__payout {
    text-align: right;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 11px;
    color: var(--color-text);
}
.player__mult { color: var(--color-text-muted); }
.player__mult--win { color: var(--color-success); font-weight: 700; }
.player__payout { color: var(--color-text-dim); }
.player__payout--win { color: var(--color-success); font-weight: 700; }

/* Chat */
.chat {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.chat.is-hidden { display: none; }

/* ---- Message list ---- */
.chat__messages {
    flex: 1 1 auto;
    min-height: 0;               /* allow shrink below content so overflow-y scrolls */
    overflow-y: auto;
    overflow-x: hidden;
    padding: 14px 12px;
    margin: 0;
    list-style: none;            /* it's a <ul> — kill the bullets */
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--color-surface-3) transparent;
}
.chat__messages::-webkit-scrollbar { width: 6px; }
.chat__messages::-webkit-scrollbar-thumb {
    background: var(--color-surface-3);
    border-radius: 999px;
}

/* ---- A single message: avatar + bubble ---- */
.chat__msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 88%;
    align-self: flex-start;      /* others on the left */
    animation: chat-pop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes chat-pop {
    from { opacity: 0; transform: translateY(6px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}

.chat__avatar {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 800;
    color: #fff;
    background:
        radial-gradient(120% 120% at 30% 20%,
            color-mix(in srgb, var(--avatar-bg, var(--color-primary)) 85%, #fff 15%),
            var(--avatar-bg, var(--color-primary)));
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35),
                inset 0 1px 0 rgba(255, 255, 255, 0.25);
    user-select: none;
}

.chat__body {
    min-width: 0;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border-soft);
    border-radius: 4px 14px 14px 14px;     /* tail toward the avatar */
    padding: 7px 11px 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.chat__meta {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 2px;
}
.chat__name {
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.01em;
    color: var(--avatar-bg, var(--color-text-muted));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}
.chat__time {
    margin-left: auto;
    flex: 0 0 auto;
    font-family: var(--font-mono);
    font-size: 9.5px;
    font-variant-numeric: tabular-nums;
    color: var(--color-text-dim);
    opacity: 0.8;
}
.chat__text {
    font-size: 12.5px;
    line-height: 1.42;
    color: var(--color-text);
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

/* ---- Own messages: mirror to the right, orange bubble, no avatar ---- */
.chat__msg--own {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.chat__msg--own .chat__avatar { display: none; }
.chat__msg--own .chat__body {
    background: linear-gradient(180deg,
        color-mix(in srgb, var(--color-primary) 92%, #fff 8%),
        var(--color-primary-deep));
    border-color: transparent;
    border-radius: 14px 14px 4px 14px;     /* tail toward the right edge */
    box-shadow: 0 2px 10px var(--color-primary-glow);
}
.chat__msg--own .chat__name { display: none; }   /* it's just "You" */
.chat__msg--own .chat__meta { justify-content: flex-end; }
.chat__msg--own .chat__time { color: rgba(255, 255, 255, 0.7); margin-left: 0; }
.chat__msg--own .chat__text { color: #fff; }

/* ---- Composer ---- */
.chat__compose {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 10px 12px 12px;
    border-top: 1px solid var(--color-border-soft);
    background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.12));
}
.chat__input {
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
    padding: 10px 16px;
    font-size: 13px;
    color: var(--color-text);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.chat__input::placeholder { color: var(--color-text-dim); }
.chat__input:focus {
    border-color: var(--color-primary);
    background: var(--color-surface);
    box-shadow: 0 0 0 3px var(--color-primary-glow);
}
.chat__send {
    background: linear-gradient(180deg, var(--color-primary), var(--color-primary-deep));
    color: #fff;
    font-family: var(--font-body);
    font-weight: 800;
    font-size: 12px;
    letter-spacing: 0.03em;
    padding: 8px 18px;
    border-radius: var(--radius-pill);
    min-width: 68px;
    box-shadow: 0 2px 10px var(--color-primary-glow);
    transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.15s ease, opacity 0.15s ease;
}
.chat__send:hover:not(:disabled) {
    box-shadow: 0 4px 16px var(--color-primary-glow);
    transform: translateY(-1px);
}
.chat__send:active:not(:disabled) { transform: translateY(0) scale(0.97); }
.chat__send:disabled {
    background: var(--color-surface-3);
    color: var(--color-text-dim);
    cursor: not-allowed;
    opacity: 0.85;
    box-shadow: none;
    transform: none;
}
/* Cooldown notice under the composer — empty (no border/space) when idle. */
.chat__hint {
    flex: 0 0 auto;
    font-size: 11px;
    line-height: 1.4;
    color: var(--color-primary);
    padding: 0 12px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.18s ease, padding 0.18s ease;
}
.chat__hint.is-active {
    max-height: 40px;
    padding: 0 12px 8px;
}

/* My Bets panel */
.mybets {
    flex: 1 1 auto;
    min-height: 0;   /* allow shrink below content so overflow-y scrolls */
    overflow-y: auto;
    padding: 0 12px 12px;
}
.mybets.is-hidden { display: none; }

/* My Bets table — Date | Bet | Result | Win */
.mybets__cols {
    display: grid;
    grid-template-columns: 1fr 0.9fr 1.1fr 1fr;
    padding: 8px;
    color: var(--color-text-dim);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-bottom: 1px solid var(--color-border-soft);
}
.col--bet, .col--win { text-align: right; }
.col--status { text-align: center; }
.mybets__rows { padding: 4px 0; }
.mybets__row {
    display: grid;
    grid-template-columns: 1fr 0.9fr 1.1fr 1fr;
    align-items: center;
    padding: 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    transition: background 0.15s ease;
}
.mybets__row:hover { background: var(--color-surface-2); }
.mybets__cell {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 11px;
    color: var(--color-text-muted);
}
.mybets__date { color: var(--color-text); font-family: var(--font-body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mybets__bet { text-align: right; color: var(--color-text); }
.mybets__statuscell { text-align: center; }
.mybets__win { text-align: right; color: var(--color-text-dim); }
.mybets__win--win { color: var(--color-success); font-weight: 700; }

/* Status pill — coloured by lifecycle (win / loss / pending). */
.mybets__pill {
    display: inline-block;
    font-family: var(--font-body);
    font-size: 10px;
    font-weight: 700;
    text-transform: capitalize;
    letter-spacing: 0.02em;
    line-height: 1;
    padding: 3px 8px;
    border-radius: var(--radius-pill);
    border: 1px solid transparent;
    white-space: nowrap;
}
/* Success / win — green */
.mybets__pill--success {
    color: var(--color-success);
    background: color-mix(in srgb, var(--color-success) 16%, transparent);
    border-color: color-mix(in srgb, var(--color-success) 32%, transparent);
}
/* Open — amber (in progress) */
.mybets__pill--open {
    color: var(--color-warning);
    background: color-mix(in srgb, var(--color-warning) 16%, transparent);
    border-color: color-mix(in srgb, var(--color-warning) 32%, transparent);
}
/* Rollback / loss — red (reversed) */
.mybets__pill--rollback,
.mybets__pill--loss {
    color: var(--color-danger);
    background: color-mix(in srgb, var(--color-danger) 14%, transparent);
    border-color: color-mix(in srgb, var(--color-danger) 30%, transparent);
}
/* Unknown / pending — muted grey */
.mybets__pill--neutral {
    color: var(--color-text-dim);
    background: var(--color-surface-3);
    border-color: var(--color-border);
}

/* Pager */
.mybets__pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    padding: var(--space-3) 0 var(--space-2);
    border-top: 1px solid var(--color-border-soft);
    margin-top: var(--space-2);
}
.mybets__pagebtn {
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease;
}
.mybets__pagebtn:hover:not(:disabled) { border-color: var(--color-primary); color: var(--color-primary); }
.mybets__pagebtn:disabled { opacity: 0.4; cursor: not-allowed; }
.mybets__pageinfo { font-size: 11px; color: var(--color-text-muted); font-variant-numeric: tabular-nums; }

/* Loading / empty / error states */
.mybets__status {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-8) var(--space-4);
    text-align: center;
}
.mybets__status-msg { margin: 0; color: var(--color-text-muted); font-size: 13px; }
.mybets__retry {
    padding: 6px 16px;
    border-radius: var(--radius-pill);
    background: var(--color-primary);
    color: #fff;
    font-weight: 700;
    font-size: 12px;
    cursor: pointer;
}
.mybets__retry:hover { background: var(--color-primary-hover); }

/* Sidebar panels hidden / shown by the tab switcher */
[data-panel].is-hidden { display: none; }


/* ==========================================================================
   9b. LANDSCAPE MOBILE — two-column: game left, bet panel right
   --------------------------------------------------------------------------
   Phones in landscape (<960px wide) get a side-by-side layout so the
   game canvas isn't crushed by the bet panel stacking below it.
   The sidebar stays a bottom-sheet reachable via the FAB.
   ========================================================================== */
@media (orientation: landscape) and (max-width: 959px) {
    .app-shell {
        grid-template-rows: auto auto 1fr;
        grid-template-columns: 1fr 260px;
        grid-template-areas:
            "header   history"
            "main     betpanel"
            "main     betpanel";
        /* Bound the shell to the viewport so the bet column scrolls internally
           (below) instead of growing the page and pushing buttons off-screen. */
        height: 100dvh;
        min-height: 0;
    }

    /* Compact header — every pixel of vertical space matters */
    .app-header { height: 40px; padding: 0 var(--space-2); }
    .brand__name { font-size: 15px; }
    .wallet { padding: 6px 10px; }
    .wallet__amount { font-size: 11px; }

    /* History strip — compact horizontal scroll above the bet panel */
    .history-strip {
        display: flex;
        padding: 4px 8px;
        gap: 4px;
        border-left: 1px solid var(--color-border-soft);
        border-bottom: 1px solid var(--color-border-soft);
        align-items: center;
    }
    .history__pill {
        height: 22px;
        min-width: 42px;
        font-size: 10px;
        padding: 0 6px;
    }

    /* Game canvas — tighter padding */
    .app-main { padding: 4px 8px; }

    /* Bet panel — right column, single-column with tabs (too narrow for two).
       min-height:0 lets the overflow-y:auto scroll within the bounded shell
       height instead of the panels overflowing off-screen. */
    .bet-row {
        grid-template-columns: 1fr;
        padding: 8px;
        padding-right: calc(8px + env(safe-area-inset-right));
        border-top: 0;
        border-left: 1px solid var(--color-border-soft);
        background: var(--color-surface);
        overflow-y: auto;
        min-height: 0;
    }

    /* Both panels stacked — no tabs needed */
    .bet-tabs { display: none; }

    /* Hide bottom bar in landscape — FAB is used instead */
    .bottom-bar { display: none !important; }

    /* Auto Play + Auto Cash Out share one row to save vertical space; the
       cashout toggle uses its short "Cashout (2.00x)" label so it fits. */
    .auto-toggles { grid-template-columns: 1fr 1fr; }
    .autoplay-tog, .cashout-tog { font-size: 8px; padding: 6px; }
    .cashout-tog__name--full { display: none; }
    .cashout-tog__name--short { display: inline; }

    /* Compact bet controls */
    .stake__input-wrap { height: 38px; }
    .stake__input { font-size: 14px; }
    .place-bet { min-height: 44px; border-radius: 10px; }
    .place-bet__title { font-size: 12px; }
    .place-bet__amount { font-size: 14px; }

    /* FAB — repositioned to sit at bottom-left of game area,
       clear of the right-side bet panel */
    .sidebar-fab {
        bottom: 12px;
        right: calc(272px + env(safe-area-inset-right));
    }

    /* Snackbar — reposition for landscape */
    .snackbar {
        bottom: 12px;
        left: 50%;
        transform: translateX(-50%);
    }
    .snackbar.is-hidden {
        transform: translateX(-50%) translateY(20px);
    }
}


/* ==========================================================================
   9b. PORTRAIT mobile — let the game fill the main row's height
   --------------------------------------------------------------------------
   The base rule locks the canvas box to 16:9, which on a portrait phone
   leaves dead space below it and keeps the box landscape-shaped — so the
   game never rotates its pitch to portrait. Here we drop the fixed ratio and
   let the container fill the `1fr` main row instead, making it taller than
   wide. The game auto-detects that (height > width) and renders its portrait
   pitch, letterboxing its own content to keep aspect ratio. `contain: size`
   (base rule) still isolates the game's ResizeObserver, so no feedback loop.
   Gated to match the shell's isMobilePortrait() (portrait + <960px).
   ========================================================================== */
@media (orientation: portrait) and (max-width: 959px) {
    .game-canvas-container {
        aspect-ratio: auto;   /* height comes from the flex row, not the width */
        flex: 1 1 auto;       /* grow to fill .game-column (= the main 1fr row) */
        max-height: none;
    }
}


/* ==========================================================================
   10. DESKTOP layout (≥960px)
   ========================================================================== */
@media (min-width: 960px) {
    .app-shell {
        grid-template-rows: var(--header-height-desktop) auto 1fr auto;
        grid-template-columns: minmax(0, 1fr) 360px;
        grid-template-areas:
            "header   header"
            "history  history"
            "main     sidebar"
            "betpanel sidebar";
        padding: 0 16px;
        gap: 0;
        /* Bound the shell to the viewport so bet panels don't overflow
           off-screen on short desktop viewports / zoomed browsers. */
        height: 100dvh;
        min-height: 0;
    }
    .app-header {
        height: var(--header-height-desktop);
        padding: 0 var(--space-3);
    }
    .wallet { padding: 8px 18px; }
    .wallet__label { display: inline; }
    .wallet__amount { font-size: 14px; }

    .brand__name { font-size: 20px; }

    /* Show conn-indicator + online-count on desktop */
    .online-count {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 6px 10px;
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-pill);
        color: var(--color-text-muted);
        font-family: var(--font-mono);
        font-size: 12px;
        font-weight: 600;
        font-variant-numeric: tabular-nums;
    }
    .online-count.is-hidden { display: none; }
    .online-count__icon { color: var(--color-primary); }
    .online-count__value { color: var(--color-text); }

    .conn-indicator {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 6px 10px;
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-pill);
        color: var(--color-text-muted);
        font-size: 11px;
        font-weight: 700;
        transition: border-color 0.2s ease, color 0.2s ease;
    }
    .conn-indicator.is-hidden { display: none; }
    .conn-indicator__dot {
        width: 7px; height: 7px;
        border-radius: 50%;
        background: var(--color-text-muted);
        flex-shrink: 0;
    }
    .conn-indicator[data-state="connected"]    { color: var(--color-text); border-color: rgba(16, 185, 129, 0.35); }
    .conn-indicator[data-state="connected"]    .conn-indicator__dot { background: var(--color-success); box-shadow: 0 0 8px var(--color-success-glow); }
    .conn-indicator[data-state="connecting"]   { border-color: rgba(251, 191, 36, 0.35); }
    .conn-indicator[data-state="connecting"]   .conn-indicator__dot { background: var(--color-warning); animation: round-status-pulse 1s infinite; }
    .conn-indicator[data-state="reconnecting"] { border-color: rgba(251, 191, 36, 0.5); color: var(--color-text); }
    .conn-indicator[data-state="reconnecting"] .conn-indicator__dot { background: var(--color-warning); animation: round-status-pulse 0.7s infinite; }
    .conn-indicator[data-state="closed"],
    .conn-indicator[data-state="failed"]       { border-color: rgba(239, 68, 68, 0.5); color: var(--color-text); }
    .conn-indicator[data-state="closed"]       .conn-indicator__dot,
    .conn-indicator[data-state="failed"]       .conn-indicator__dot { background: var(--color-danger); }

    /* Larger pills on desktop */
    .history__pill { height: 28px; min-width: 56px; font-size: 12px; }
    .history-strip { padding: 10px 16px; gap: 8px; }

    /* Desktop just uses the same 16:9 inherited from base — kept here
       as an explicit override so future tweaks (e.g. larger min-height)
       have a place to land. */
    .app-main { padding: 12px 0 12px 0; }
    .game-canvas-container { min-height: 380px; }

    /* Bet panels side-by-side; hide the tabs */
    .bet-tabs { display: none; }
    .bet-row {
        background: transparent;
        border-top: 0;
        padding: 12px 0 16px;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 14px;
        overflow-y: auto;
        min-height: 0;
    }
    /* Show BOTH panels regardless of [data-active-bet] */
    body[data-active-bet] .bet-row .bet-panel { display: grid !important; }
    .bet-panel {
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-lg);
        padding: 14px;
        box-shadow: var(--shadow-card);
        gap: 10px;
    }
    .stake__label {
        display: block;
        font-size: 10px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.1em;
        color: var(--color-text-dim);
        padding: 0 2px;
    }
    .stake__input { font-size: 18px; }

    /* Sidebar — static column, always visible */
    .sidebar {
        grid-area: sidebar;
        position: static;
        transform: none !important;
        max-height: none;
        margin: 12px 0 12px 16px;
        border-radius: var(--radius-lg);
        border: 1px solid var(--color-border);
        box-shadow: var(--shadow-card);
    }
    .sidebar__handle { display: none; }
    .sidebar-fab, .sidebar-backdrop, .bottom-bar { display: none !important; }
}


/* ==========================================================================
   10b. SHORT DESKTOP — wide screen, short viewport
   --------------------------------------------------------------------------
   On desktop-width screens (≥960px) with limited vertical space (≤724px),
   the bet panels overlap the game canvas. Switch to a landscape-style
   two-column layout: game left, bet panels right — just like landscape
   mobile, but at desktop widths. The sidebar reverts to its mobile overlay
   so the right column is free for bet panels.
   ========================================================================== */
@media (min-width: 960px) and (max-height: 724px) {
    .app-shell {
        grid-template-rows: auto auto 1fr;
        grid-template-columns: 1fr 300px;
        grid-template-areas:
            "header   history"
            "main     betpanel"
            "main     betpanel";
        height: 100dvh;
        min-height: 0;
    }

    /* Game canvas — drop the desktop min-height so it can fill the row */
    .game-canvas-container { min-height: 0; }
    .app-main { padding: 8px; }

    /* History strip — compact, right column top */
    .history-strip {
        display: flex;
        padding: 4px 8px;
        gap: 4px;
        border-left: 1px solid var(--color-border-soft);
        border-bottom: 1px solid var(--color-border-soft);
        align-items: center;
    }
    .history__pill { height: 24px; min-width: 48px; font-size: 11px; }

    /* Bet row — right column, single-column stack, scrollable */
    .bet-row {
        grid-template-columns: 1fr;
        padding: 8px;
        border-top: 0;
        border-left: 1px solid var(--color-border-soft);
        background: var(--color-surface);
        overflow-y: auto;
        min-height: 0;
    }
    .bet-tabs { display: none; }

    /* Override desktop's larger bet-panel sizing */
    .bet-panel { padding: 8px; gap: 6px; }
    .stake__label { display: none; }

    /* Compact bet controls — match landscape mobile */
    .auto-toggles { grid-template-columns: 1fr 1fr; }
    .autoplay-tog, .cashout-tog { font-size: 9px; padding: 6px; }
    .cashout-tog__name--full { display: none; }
    .cashout-tog__name--short { display: inline; }
    .place-bet { min-height: 44px; border-radius: 10px; }
    .place-bet__title { font-size: 12px; }
    .place-bet__amount { font-size: 14px; }
    .stake__input-wrap { height: 38px; }
    .stake__input { font-size: 14px; }

    /* Sidebar — revert to mobile overlay (undo desktop static positioning).
       !important needed to override desktop's `transform: none !important`. */
    .sidebar {
        position: fixed !important;
        inset: auto 0 0 0;
        transform: translateY(100%) !important;
        max-height: 72dvh;
        margin: 0;
        border-radius: 18px 18px 0 0;
        border: none;
        border-top: 1px solid var(--color-border);
        box-shadow: 0 -20px 50px -10px rgba(0, 0, 0, 0.6);
    }
    .sidebar[data-open="true"] { transform: translateY(0) !important; }
    .sidebar__handle { display: flex; }
    .sidebar-fab { display: flex !important; bottom: 12px; right: calc(312px + env(safe-area-inset-right)); }
    .sidebar-backdrop { display: block !important; }
    .bottom-bar { display: none !important; }
}


/* ==========================================================================
   11. MINI MODE — body.mini { … }
   --------------------------------------------------------------------------
   Triggered by ?mini=true via mini-mode.ts adding `body.mini`.
   Strips chrome to the essentials: micro history strip, canvas, bet
   bar. No header, no sidebar, no auto controls, no quick-pills.
   ========================================================================== */
body.mini .app-header,
body.mini .sidebar,
body.mini .sidebar-fab,
body.mini .sidebar-backdrop,
body.mini .bet-actions,
body.mini .quick-stakes {
    display: none !important;
}

body.mini .app-shell {
    grid-template-rows: auto 1fr auto;
    grid-template-columns: 1fr;
    grid-template-areas:
        "history"
        "main"
        "betpanel";
    padding: 0;
}

body.mini .history-strip {
    padding: 4px 8px;
    gap: 4px;
}
body.mini .history__pill {
    height: 18px;
    min-width: 38px;
    padding: 0 6px;
    font-size: 10px;
}

body.mini .app-main { padding: 0 8px 4px; }
body.mini .game-canvas-container {
    /* Mini keeps the same 16:9 as desktop/mobile for predictability. */
    min-height: 0;
}
body.mini .round-overlay__big { font-size: clamp(48px, 14vw, 96px); }
body.mini .round-overlay__sub { font-size: 10px; }
body.mini .round-status { padding: 4px 8px; font-size: 9px; }

body.mini .bet-row {
    padding: 6px 8px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    background: var(--color-surface);
    border-top: 1px solid var(--color-border-soft);
}
body.mini .bet-tabs {
    margin-bottom: 6px;
    padding: 2px;
    border-radius: 9px;
}
body.mini .bet-tabs__tab {
    padding: 5px;
    font-size: 10px;
}
body.mini .bet-panel { gap: 6px; }
body.mini .stake__input-wrap { height: 38px; }
body.mini .stepper { width: 32px; font-size: 18px; }
body.mini .place-bet { min-height: 44px; border-radius: 11px; }
body.mini .place-bet__title { font-size: 12px; }
body.mini .place-bet__amount { font-size: 16px; }

/* Mini + landscape: side-by-side, no header, no history */
@media (orientation: landscape) and (max-width: 959px) {
    body.mini .app-shell {
        grid-template-rows: 1fr;
        grid-template-columns: 1fr 220px;
        grid-template-areas: "main betpanel";
    }
    body.mini .history-strip { display: none; }
    body.mini .bet-row {
        padding: 6px;
        padding-right: calc(6px + env(safe-area-inset-right));
        border-top: 0;
        border-left: 1px solid var(--color-border-soft);
    }
}


/* ==========================================================================
   12. UTILITY + ACCESSIBILITY
   ========================================================================== */
.is-hidden { display: none !important; }

/* Snackbar — appears on connection state changes */
.snackbar {
    position: fixed;
    left: 50%;
    bottom: calc(320px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 60;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    padding: 10px 14px;
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-cta);
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    opacity: 1;
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.snackbar.is-hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
    pointer-events: none;
}
@media (min-width: 960px) {
    .snackbar { bottom: 24px; }
}
/* Transient notice variants (rejected bet/cashout reasons, etc.). */
.snackbar--error { border-color: var(--color-danger); color: var(--color-text); }
.snackbar--error .snackbar__icon { background: var(--color-danger); }
.snackbar--info  .snackbar__icon { background: var(--color-primary); }

/* Terminal "session ended" overlay — full-screen, blocking, with reload. */
.session-ended {
    position: fixed;
    inset: 0;
    z-index: 200;          /* above the snackbar (60) and everything else */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-5);
    background: rgba(8, 9, 15, 0.88);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.session-ended.is-hidden { display: none; }
.session-ended__box {
    width: min(92vw, 380px);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-6) var(--space-5);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}
.session-ended__icon { font-size: 32px; line-height: 1; color: var(--color-warning); }
.session-ended__title {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 800;
}
.session-ended__msg {
    margin: 0;
    color: var(--color-text-muted);
    font-size: 14px;
    line-height: 1.5;
}
.session-ended__reload {
    margin-top: var(--space-2);
    padding: 10px 22px;
    border-radius: var(--radius-pill);
    background: var(--color-primary);
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    box-shadow: var(--shadow-cta);
    transition: background 0.15s ease;
}
.session-ended__reload:hover { background: var(--color-primary-hover); }

/* Provably-fair verification popup (native <dialog>) */
.verify-modal,
.fairness-modal {
    /* Wide enough that a 64-char hash fits on one line at the desktop
       end (≈640px content). On phones 94vw caps it and the mono values
       scroll horizontally instead (see --mono below). */
    width: min(94vw, 680px);
    max-height: 86vh;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}
/* Flex column ONLY when open — so the head/tabs stay fixed and the body
   scrolls within max-height. (Setting display on the base rule would defeat
   a closed <dialog>'s default display:none and render it in normal flow.) */
.verify-modal[open],
.fairness-modal[open] {
    display: flex;
    flex-direction: column;
}
/* The info popup has no long hashes — keep it narrower. */
.fairness-modal { width: min(94vw, 460px); }
.verify-modal::backdrop,
.fairness-modal::backdrop {
    background: rgba(8, 9, 15, 0.66);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* ---- Game-info popup: header button, tabs, content ---- */
.fairness-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 10px;
    border-radius: var(--radius-pill);
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: 12px;
    font-weight: 600;
    transition: color 0.15s ease, border-color 0.15s ease;
}
.fairness-btn:hover { color: var(--color-text); border-color: var(--color-primary); }
.fairness-btn svg { width: 14px; height: 14px; color: var(--color-primary); }
@media (max-width: 600px) {
    .fairness-btn__label { display: none; }
    .fairness-btn { padding: 0 8px; }
}

.fairness-tabs {
    display: flex;
    gap: var(--space-1);
    padding: 0 var(--space-5);
    border-bottom: 1px solid var(--color-border-soft);
}
.fairness-tab {
    padding: var(--space-3) var(--space-2);
    margin-bottom: -1px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--color-text-dim);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease;
}
.fairness-tab:hover { color: var(--color-text-muted); }
.fairness-tab[data-active] {
    color: var(--color-text);
    border-bottom-color: var(--color-primary);
}
.fairness-panel.is-hidden { display: none; }

.fairness-modal__intro {
    margin: 0 0 var(--space-4);
    color: var(--color-text-muted);
    font-size: 13px;
    line-height: 1.5;
}
.fairness-modal__stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
    margin-bottom: var(--space-5);
}
.fairness-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-3);
    background: var(--color-surface-2);
    border: 1px solid var(--color-border-soft);
    border-radius: var(--radius-md);
}
.fairness-stat__label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-dim);
}
.fairness-stat__value {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 15px;
    font-weight: 700;
    color: var(--color-text);
}
.fairness-modal__h {
    margin: var(--space-4) 0 var(--space-2);
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
    color: var(--color-text);
}
.fairness-modal__p {
    margin: 0 0 var(--space-3);
    color: var(--color-text-muted);
    font-size: 12px;
    line-height: 1.6;
}
.fairness-list {
    margin: 0;
    padding-left: 1.2em;
    color: var(--color-text-muted);
    font-size: 12px;
    line-height: 1.7;
    list-style: disc;            /* override the global `ul { list-style:none }` */
}
.fairness-list li { margin-bottom: var(--space-2); }
.fairness-list strong { color: var(--color-text); font-weight: 700; }
.fairness-list--steps { padding-left: 1.4em; list-style: decimal; }
.verify-modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--color-border-soft);
}
.verify-modal__title {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    margin: 0;
}
.verify-modal__close {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--color-surface-2);
    color: var(--color-text-muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.verify-modal__close:hover {
    background: var(--color-surface-3);
    color: var(--color-text);
}
.verify-modal__body {
    padding: var(--space-5);
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.verify-modal__status {
    margin: 0;
    color: var(--color-text-muted);
    font-size: 13px;
    text-align: center;
    padding: var(--space-4) 0;
}
.verify-modal__status--error { color: var(--color-danger); }

.verify-modal__crash {
    font-family: var(--font-display);
    font-variant-numeric: tabular-nums;
    font-size: 40px;
    font-weight: 800;
    text-align: center;
    color: var(--color-primary);
    margin-bottom: var(--space-4);
}

.verify-modal__list {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}
.verify-modal__row {
    display: grid;
    /* minmax(0, …) lets the value cell shrink below its content width so
       the mono values can scroll instead of forcing the row wider. */
    grid-template-columns: 104px minmax(0, 1fr);
    gap: var(--space-3);
    align-items: start;
    padding: var(--space-2) 0;
    border-top: 1px solid var(--color-border-soft);
}
.verify-modal__row:first-child { border-top: none; }
.verify-modal__key {
    color: var(--color-text-dim);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding-top: 2px;
}
.verify-modal__val {
    font-size: 13px;
    color: var(--color-text);
    min-width: 0;
    word-break: break-word;
}
.verify-modal__val--mono {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--color-text-muted);
    /* Keep hashes on one line. On desktop the wider dialog fits the full
       64 chars; on mobile the line stays intact and scrolls sideways
       rather than wrapping into an unreadable block. */
    white-space: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.verify-modal__val--mono::-webkit-scrollbar { display: none; }

.verify-modal__badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 700;
}
.verify-modal__badge--ok {
    color: var(--color-success);
    background: var(--color-success-glow);
}
.verify-modal__badge--bad {
    color: var(--color-danger);
    background: var(--color-danger-glow);
}
.verify-modal__badge--neutral {
    color: var(--color-text-muted);
    background: var(--color-surface-2);
    font-weight: 600;
}

.verify-modal__verify {
    margin-top: var(--space-5);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border-soft);
}
.verify-modal__link {
    display: inline-flex;
    align-items: center;
    color: var(--color-primary);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
}
.verify-modal__link:hover { color: var(--color-primary-hover); text-decoration: underline; }
.verify-modal__note {
    margin: var(--space-2) 0 0;
    color: var(--color-text-dim);
    font-size: 11px;
    line-height: 1.5;
}

/* "How is this calculated?" disclosure — collapses the algorithm/constants
   that don't change per round. */
.verify-modal__details {
    margin-top: var(--space-3);
    border-top: 1px solid var(--color-border-soft);
    padding-top: var(--space-3);
}
.verify-modal__summary {
    cursor: pointer;
    color: var(--color-text-muted);
    font-size: 12px;
    font-weight: 600;
    list-style: none;
    user-select: none;
}
.verify-modal__summary::-webkit-details-marker { display: none; }
.verify-modal__summary::before {
    content: '▸';
    display: inline-block;
    width: 1.2em;
    color: var(--color-text-dim);
}
.verify-modal__details[open] .verify-modal__summary::before { content: '▾'; }
.verify-modal__summary:hover { color: var(--color-text); }
.verify-modal__details .verify-modal__list { margin-top: var(--space-2); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==========================================================================
   CHAT TEMPORARILY DISABLED (2026-06) — remove this whole block to re-enable.
   Also set CHAT_ENABLED = true in src/services/signalr-service.ts to reconnect.
   Hides the Chat tab + panel (sidebar) and the bottom-bar Chat tab so the
   feature is invisible while the chat hub is not connected.
   ========================================================================== */
.sidebar__tab[data-tab="chat"],
[data-panel="chat"],
.bottom-bar__tab[data-bar-tab="chat"] {
    display: none !important;
}
