.user-profile-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgb(0 0 0 / 51%);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Same shell as /game/:id, /security and /investment: the overlay is the
       scroll container, so the scrollbar sits on the page edge. */
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
}
.user-profile-modal {
    background: #151515;
    color: #fff;
    border-radius: 20px;
    width: 90%;
    max-width: 1100px;
    max-height: none;
    overflow: visible;
    margin: auto;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
    position: relative;
}
.user-profile-modal-close {
    position: absolute;
    top: 24px;
    right: 30px;
    z-index: 5;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    color: #cfd3da;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.2s;
}
.user-profile-modal-close:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    transform: scale(1.05);
}
.user-profile-modal-body {
    padding: 12px 20px 20px;
    position: relative;
}
.modal-columns {
    display: grid;
    grid-template-columns: minmax(240px, 0.8fr) 2.2fr;
    gap: 20px;
    align-items: stretch;
}
@media (max-width: 1024px) {
    .modal-columns { grid-template-columns: 1fr; }
}
/* Shown instead of the columns when the requested username does not exist. */
.modal-notfound {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    min-height: 380px;
    padding: 48px 20px;
    text-align: center;
}
.modal-notfound::before {
    content: '';
    position: absolute;
    width: 280px;
    height: 280px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 255, 204, 0.12), rgba(0, 255, 204, 0) 68%);
    filter: blur(12px);
    pointer-events: none;
}
.modal-notfound-code {
    position: relative;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 92px;
    font-weight: 800;
    line-height: 0.9;
    letter-spacing: 6px;
    padding-left: 6px;
    background: linear-gradient(180deg, #00ffcc 0%, #00b18f 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: #00ffcc;
    filter: drop-shadow(0 8px 28px rgba(0, 255, 204, 0.28));
}
.modal-notfound-text {
    position: relative;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: #8a8f98;
}
.modal-left, .modal-right, .modal-left-sec, .modal-right-sec {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    padding: 20px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    min-width: 0;
}
.modal-left, .modal-left-sec {
    display: flex;
    flex-direction: column;
}
.modal-right-sec { overflow: auto; }
.modal-sec-menu { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.modal-sec-btn { width: 100%; text-align: left; background: transparent; border: none; color: #ddd; padding: 10px 12px; border-radius: 10px; cursor: pointer; display: flex; align-items: center; gap: 10px; font-family: 'Inter', sans-serif; }
.modal-sec-btn:hover { background: rgba(0,255,204,0.1); color: #00ffcc; }
.modal-sec-btn.active { background: rgba(0,255,204,0.15); color: #00ffcc; box-shadow: inset 3px 0 0 rgba(0,255,204,0.7); }
.modal-right-sec .security-section { margin: 0; width: 100%; max-width: 100%; }
.modal-right-sec .qr-container { text-align: center; margin: 20px 0; }
.modal-right-sec .qr-container h3 { color: #fff; }
.modal-right-sec .secret-code { background: rgba(0,0,0,0.3); padding: 12px; border-radius: 8px; margin-top: 12px; word-break: break-all; color: #00c6a3; }
/* The security panel reuses the shared /security alert, form and button
   styles from styles.css (amber warning alert, cyan info alert, dark-red
   danger button). The old /security page is the reference for the 2FA
   enable/disable content, so there are no compact colour overrides here. */
/* The game stylesheet only defines a `.strong` class, not the element, and
   the alert text is already near-white at 14px. Set the weight explicitly so
   <strong> is clearly bold inside the security panel. */
.modal-right-sec .alert-text strong {
    font-weight: 700;
    color: #fff;
}
.modal-right-sec .success-alert { display:flex; gap:12px; align-items:flex-start; padding:20px; border-radius:16px; margin-bottom:24px; background: rgba(0,255,153,0.08); border:1px solid rgba(0,255,153,0.3); color:#7dffc4; }
.modal-right-sec .security-skeleton-card { min-height: 420px; }
.modal-right-sec .qr-container svg { display: block; width: 100%; height: 100%; }
.modal-right-sec .alert-text button.modal-sec-btn { margin-left: 0; }
/* Disable 2FA button styling for the security panel. */
.modal-right-sec .submit-btn.danger {
    background: linear-gradient(183deg, #f443364d, rgb(244 67 54 / 85%));
    border: 1px solid #F44336;
    color: #fff;
    box-shadow: 0 12px 32px rgb(0 255 204 / 0%), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
/* No amber glow on the security panel alerts. */
.modal-right-sec .warning-alert {
    box-shadow: 0 12px 32px rgb(0 255 204 / 0%), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
/* Same holographic icon treatment the old /security alerts used. */
.modal-right-sec .alert-icon i {
    background: linear-gradient(267deg, #00ffcc 0%, #00d4aa 25%, #4ecdc4 50%, #00ffcc 75%, #00d4aa 100%);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: holographicShift 3s ease-in-out infinite;
    position: relative;
}
.ml-profile {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
    margin-bottom: 20px;
}
.ml-name {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}
.ml-avatar {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(0, 255, 204, 0.12);
    border: 1px solid rgba(0, 255, 204, 0.3);
    color: #00ffcc;
    font-size: 16px;
}
.modal-username-large {
    font-size: 19px;
    font-weight: 700;
    letter-spacing: 0.2px;
    color: #fff;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.ml-meta {
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.modal-joined-label {
    font-size: 11px;
    color: #8a8f98;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.modal-joined-date {
    font-size: 13px;
    color: #eee;
}
.modal-tip-btn {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    border: 1px solid rgba(0, 255, 204, 0.4);
    border-radius: 13px;
    font-size: 14px;
    font-weight: 700;
    color: #00ffcc;
    background: rgba(0, 255, 204, 0.1);
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: 0.2s;
}
.modal-tip-btn:hover {
    background: rgba(0, 255, 204, 0.2);
    color: #00ffcc;
    text-decoration: none;
}
.modal-stats {
    display: flex;
    flex-direction: column;
    position: relative;
    padding-top: 8px;
}
.modal-stats::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.28) 50%, rgba(255, 255, 255, 0) 100%);
}
.stat-row {
    /* label | amount (right-aligned) | fixed currency column, so every amount
       lines up on the right regardless of how many digits it has. */
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: baseline;
    column-gap: 6px;
    padding: 9px 0;
    font-size: 13px;
}
.stat-row-label {
    color: #9aa0a6;
}
.stat-row-value {
    color: #959ba1;
    font-weight: 500;
    text-align: right;
    /* /play never loads Inter, so this falls back to the system font. Force
       equal-width figures so values like 0.00011113 and 0.59403767 line up
       regardless of how many digits they have. font-feature-settings is kept
       alongside font-variant-numeric for older engines. */
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1, "lnum" 1;
}
.btc-symbol {
    font-weight: 700;
}
/* The currency glyph is always rendered so the column has an identical width
   on every row; non-BTC rows hide it but still reserve the space. */
.btc-symbol--ghost {
    visibility: hidden;
}
.profit-positive { color: #0fc; }
.profit-negative { color: #ff6b6b; }
.metrics-section .section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 8px 0;
    font-size: 15px;
}
.metrics-section .section-title::before {
    content: '';
    width: 4px;
    height: 20px;
    background: linear-gradient(135deg, #00ffcc, #00d4aa);
    border-radius: 2px;
    box-shadow: 0 0 8px rgba(0, 255, 204, 0.5);
}
.modal-chart-wrap {
    position: relative;
    min-width: 0;
    overflow: hidden;
}
.modal-chart-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(21, 21, 21, 0.2);
    pointer-events: none;
}
.modal-pagination {
    margin-top: 16px;
    display: flex;
    gap: 12px;
    justify-content: center;
}
.modal-pagination a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    color: #e6e8ee;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}
.modal-pagination a:hover {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.1));
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    color: #fff;
}
.modal-pagination a.is-disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: default;
}
/* Loading glance: the shimmer sweeps inside each card of the modal instead
   of across the whole modal. Driven by the `is-loading` class the modals put
   on their content wrapper while fetching. */
.modal-skeleton-glance {
    position: absolute;
    top: 0;
    left: -60%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.12) 50%, rgba(255,255,255,0) 100%);
    animation: modal-glance 1.4s ease-in-out infinite;
    filter: blur(2px);
}

.is-loading {
    position: relative;
}

.is-loading .game-header-card,
.is-loading .players-section,
.is-loading .hash-section,
.is-loading .bet-header-card,
.is-loading .modal-left,
.is-loading .modal-right,
.is-loading .modal-left-sec,
.is-loading .modal-right-sec {
    position: relative;
    overflow: hidden;
}

.is-loading .game-header-card::after,
.is-loading .players-section::after,
.is-loading .hash-section::after,
.is-loading .bet-header-card::after,
.is-loading .modal-left::after,
.is-loading .modal-right::after,
.is-loading .modal-left-sec::after,
.is-loading .modal-right-sec::after {
    content: '';
    position: absolute;
    top: 0;
    left: -60%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.12) 50%, rgba(255,255,255,0) 100%);
    animation: modal-glance 1.4s ease-in-out infinite;
    filter: blur(2px);
    pointer-events: none;
    border-radius: inherit;
}
@keyframes modal-glance {
    0% { left: -60%; }
    100% { left: 160%; }
}

/* Chart tooltip balloon + SVG furniture.
   These rules live in client_new/styles.css, which is loaded on the old
   profile page (via layouts/layout.html) but NOT on /play. The chart markup
   is unclassed SVG keyed off #chartdiv, so porting the rules here makes the
   modal chart match the previous profile-page design exactly. */
.amcharts-user-balloon {
    --tone: #00ffcc;
    box-sizing: border-box;
    min-width: 228px;
    max-width: 268px;
    overflow: hidden;
    border-radius: 12px;
    background: rgba(18, 18, 18, 0.88);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    box-shadow: 0 0 0 2px var(--tone),
                0 10px 30px rgba(0, 0, 0, 0.3),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
    color: #e6e8ee;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 11.52px;
    font-weight: 400;
    line-height: 1.35;
    text-align: center;
}
.amcharts-user-balloon--win  { --tone: #2ecc71; }
.amcharts-user-balloon--loss { --tone: #ec644b; }
.amcharts-user-balloon--flat { --tone: #80808033; }
.amcharts-user-balloon__head {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 12px 14px 13px;
    background: transparent;
}
.amcharts-user-balloon__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
}
.amcharts-user-balloon__game {
    margin: 0;
    color: rgba(255, 255, 255, 0.6);
    font-size: 9.92px;
    font-weight: 800;
    letter-spacing: .07em;
    text-transform: uppercase;
    white-space: nowrap;
}
.amcharts-user-balloon__time {
    margin: 0;
    color: rgba(255, 255, 255, 0.6);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 10.88px;
    font-weight: 500;
    white-space: nowrap;
}
.amcharts-user-balloon__profit {
    margin: 0;
    color: #e6e8ee;
    font-size: 18.88px;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -.03em;
    font-variant-numeric: tabular-nums;
}
.amcharts-user-balloon__profit--win  { color: #2ecc71; }
.amcharts-user-balloon__profit--loss { color: #ec644b; }
.amcharts-user-balloon__profit--flat { color: #e6e8ee; }
.amcharts-user-balloon__stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
    margin: 0;
    padding: 0;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border-top: 1px solid rgba(255, 255, 255, 0.15);
}
.amcharts-user-balloon__stat {
    display: grid;
    gap: 4px;
    min-width: 0;
    padding: 10px 8px 11px;
    text-align: center;
    background: transparent;
}
.amcharts-user-balloon__stat + .amcharts-user-balloon__stat {
    border-left: 1px solid rgba(255, 255, 255, 0.15);
}
.amcharts-user-balloon__stat-label {
    color: rgba(255, 255, 255, 0.6);
    font-size: 8.96px;
    font-weight: 800;
    letter-spacing: .09em;
    text-transform: uppercase;
}
.amcharts-user-balloon__stat-value {
    color: #e6e8ee;
    font-size: 12.8px;
    font-weight: 800;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.amcharts-user-balloon__stat-value--bust { color: #ec644b; }

#chartdiv svg text {
    fill: rgba(255, 255, 255, 0.5) !important;
    font-family: 'Inter', -apple-system, 'Segoe UI', sans-serif !important;
}
#chartdiv svg path[stroke-width="1"] {
    stroke: rgba(255, 255, 255, 0.07) !important;
}
/* Interactive chart points (bullet circles). amCharts only assigns a pointer
   cursor when a graph URL is set; these bullets use clickGraphItem instead, so
   the hover cursor is applied here. Only <circle> elements (the round bullets
   and the cursor bullet) are targeted - grid lines, ticks and the data line are
   <path>, so they keep the default cursor. */
#chartdiv svg circle {
    cursor: pointer;
}
#chartdiv svg path[stroke-width="1"][d^="M0.5,"] {
    stroke-opacity: 0 !important;
}

/* Security routes (/security/update-2fa and /security/update-password) use
   the same modal width and page-level scroll as the game details modal
   (/game/:id): the overlay scrolls and the box grows with its content, so the
   scrollbar sits on the page edge instead of inside the popup. */
.security-modal-overlay {
    align-items: flex-start;
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
}
.security-modal,
.security-modal .user-profile-modal-body,
.security-modal .modal-columns {
    box-sizing: border-box;
}
.security-modal .user-profile-modal-body {
    max-width: 100%;
}
.security-modal-overlay .security-modal {
    width: 90%;
    max-width: 1100px;
    max-height: none;
    overflow: visible;
    margin: auto;
}

/* Security tabs on phones: hide the left panel and show the tab menu as a
   horizontal icon-only row under the card title. The active tab gets a 1px
   underline instead of the desktop filled background/inset bar. */
.modal-sec-menu--mobile { display: none; }
@media (max-width: 767px) {
    .security-modal .modal-left-sec { display: none; }
    .modal-sec-menu--mobile {
        display: flex;
        flex-direction: row;
        justify-content: center;
        gap: 8px;
        margin: 0 0 16px;
    }
    .modal-sec-menu--mobile .modal-sec-btn {
        width: auto;
        justify-content: center;
        padding: 8px 16px;
        border-radius: 0;
        border-bottom: 1px solid transparent;
        background: transparent;
        box-shadow: none;
    }
    .modal-sec-menu--mobile .modal-sec-btn i { font-size: 1rem; }
    .modal-sec-menu--mobile .modal-sec-btn.active {
        background: transparent;
        box-shadow: none;
        color: #00ffcc;
        border-bottom-color: rgba(0, 255, 204, 0.7);
    }
}

/* Success notice after enabling/disabling 2FA or changing the password.
   It mirrors the deposit toast (top centre, auto-dismiss after 8s) and sits
   above the security modal overlay. */
#security-message-container {
    background: linear-gradient(172deg, rgba(0, 255, 204, 0.1), rgb(0 212 170 / 23%));
    border: 1px solid rgba(0, 255, 204, 0.3);
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 50%;
    max-width: 600px;
    min-width: 300px;
    padding: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    box-sizing: border-box;
    backdrop-filter: blur(15px);
    animation: security-slide-in 0.3s ease-out;
    text-decoration: none;
    border-radius: 0 0 10px 10px;
    text-align: center;
    z-index: 10001;
}
#security-message-container.is-error {
    border: 1px solid rgba(244, 67, 54, 0.35);
    background: linear-gradient(183deg, #f443364d, rgb(244 67 54 / 28%));
    color: #fff;
}
#security-message-container.hide { display: none; }
#security-message-container > span { overflow-y: hidden; padding-right: 20px; display: block; font-size: 0.7rem; line-height: 1.2rem; font-weight: 800; }
#security-message-container span > a,
#security-message-container span > span { color: #fff; font-size: 0.8rem; line-height: 1.2rem; font-weight: 800; }
#security-message-container .close-message { position: absolute; top: 0; right: 0; cursor: pointer; }
#security-message-container .close-message i { color: #fff; font-size: 0.8rem; line-height: 1.2rem; padding-right: 0.2rem; }
@keyframes security-slide-in {
    from { transform: translate(-50%, -8px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}
@media (max-width: 767px) {
    #security-message-container { width: 90%; min-width: 0; }
}
@media (max-width: 640px) {
    .security-modal-overlay {
        padding: 0;
        padding-top: 44px;
    }
    .security-modal-overlay .security-modal {
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: 16px;
    }
}

/* Remove monospace only for Net profit value in user profile */
.stat-row .stat-row-value.profit-positive {
    font-family: inherit;
}

/* Remove monospace for Net profit value in user profile (both positive and negative) */
.stat-row .stat-row-value.profit-positive,
.stat-row .stat-row-value.profit-negative {
    font-family: inherit;
}

/* Phones: every /play popup is full-bleed with the scrollbar on the page edge,
   matching /game/:id. Point-of-use rule (2 classes) so the per-popup mobile
   blocks in the later stylesheets can still refine their own content. */
@media (max-width: 640px) {
    .user-profile-modal-overlay {
        padding: 0;
        padding-top: 44px;
        /* Pin to the top like /game/:id so the 44px gap is real and a tall
           popup cannot have its top clipped by vertical centering. */
        align-items: flex-start;
        justify-content: flex-start;
    }
    .user-profile-modal-overlay .user-profile-modal {
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: 16px;
    }
}
