/* ==========================================================
   PLATINUM NETWORK - LAYOUT COMPACT FIX
   Fixes: right-side horizontal overflow, excess page height
========================================================== */

html, body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden !important;
    margin: 0;
    padding: 0;
}

/* NOTE: #root previously had its own "overflow-x: hidden" rule here.
   Removed - per the CSS overflow spec, setting only overflow-x on an
   element implicitly computes its overflow-y to 'auto' (since 'visible'
   can't be paired with a non-visible value on the other axis). If #root
   has any height constraint, that implicit auto-computation turns #root
   into its OWN scrollable box with a visible inner scrollbar - this was
   very likely the real cause of both the "second scrollbar" and the
   persistent scroll-jump/shake bug. html/body already clip horizontal
   overflow, so #root doesn't need this rule at all. */

/* Anything using 100vw as a width causes the right-side overflow bug
   whenever a scrollbar is present (vw includes the scrollbar's width).
   Force those back to 100%. */
[style*="100vw"], .w-screen {
    width: 100% !important;
    max-width: 100% !important;
}

/* Prevent any element from being wider than its container */
* {
    max-width: 100%;
}

img, svg, video, canvas, iframe, table {
    max-width: 100% !important;
    height: auto;
}

/* Reduce default excess vertical spacing site-wide (compact pass) */
section, .section, .page-section {
    padding-top: clamp(20px, 4vw, 48px) !important;
    padding-bottom: clamp(20px, 4vw, 48px) !important;
}

.container, .container-fluid, .max-w-7xl, .max-w-6xl {
    padding-left: 12px !important;
    padding-right: 12px !important;
}

@media (max-width: 768px) {
    section, .section, .page-section {
        padding-top: 20px !important;
        padding-bottom: 20px !important;
    }
    .mb-8 { margin-bottom: 1rem !important; }
    .mb-6 { margin-bottom: 0.75rem !important; }
    .py-8 { padding-top: 1rem !important; padding-bottom: 1rem !important; }
    .py-6 { padding-top: 0.75rem !important; padding-bottom: 0.75rem !important; }
}

/* ==========================================================
   Footer "Join Our Community" social icon row - was wrapping
   into 2-3 rows on mobile because each button is a large 64px
   circle. Shrink buttons + tighten gap so they fit in fewer rows.
========================================================== */

div:has(> a[title="Telegram"]) {
    gap: 8px !important;
    row-gap: 8px !important;
    flex-wrap: wrap !important;
}

a[title="Telegram"], a[title="Twitter"], a[title="YouTube"],
a[title="Instagram"], a[title="Discord"] {
    padding: 10px !important;
}

a[title="Telegram"] svg, a[title="Twitter"] svg, a[title="YouTube"] svg,
a[title="Instagram"] svg, a[title="Discord"] svg {
    width: 20px !important;
    height: 20px !important;
}

@media (max-width: 420px) {
    a[title="Telegram"], a[title="Twitter"], a[title="YouTube"],
    a[title="Instagram"], a[title="Discord"] {
        padding: 8px !important;
    }
    a[title="Telegram"] svg, a[title="Twitter"] svg, a[title="YouTube"] svg,
    a[title="Instagram"] svg, a[title="Discord"] svg {
        width: 18px !important;
        height: 18px !important;
    }
}

/* ==========================================================
   Remove Discord from the social row entirely
========================================================== */

a[title="Discord"] {
    display: none !important;
}

/* ==========================================================
   Shrink "Download APK" and "Play Store" buttons
========================================================== */

a[title="Download APK"], a[title="Play Store"] {
    padding: 8px !important;
}

a[title="Download APK"] svg, a[title="Play Store"] svg {
    width: 18px !important;
    height: 18px !important;
}

@media (max-width: 420px) {
    a[title="Download APK"], a[title="Play Store"] {
        padding: 6px !important;
    }
    a[title="Download APK"] svg, a[title="Play Store"] svg {
        width: 16px !important;
        height: 16px !important;
    }
}

/* Real Google Play badge instead of the generic icon.
   Upload the official badge (from Google's own brand-assets page)
   to /static/media/playstore-icon.png - this rule then swaps it in
   automatically. Until that file is uploaded this has no visible effect. */

a[title="Play Store"] svg {
    display: none;
}

a[title="Play Store"] {
    background-image: url('/static/media/playstore-icon.png');
    background-size: 60% 60%;
    background-position: center;
    background-repeat: no-repeat;
}

/* ==========================================================
   Dashboard page only (detected via the mining coin element,
   which only exists on Dashboard) - reduce overall height/width
========================================================== */

body:has(.mining-scene-visual) .max-w-7xl,
body:has(.mining-scene-visual) .max-w-6xl {
    max-width: 1100px !important;
}

body:has(.mining-scene-visual) .p-6 {
    padding: 1rem !important;
}

body:has(.mining-scene-visual) .gap-6 {
    gap: 0.75rem !important;
}

body:has(.mining-scene-visual) .mb-8 {
    margin-bottom: 0.75rem !important;
}

body:has(.mining-scene-visual) .rounded-2xl {
    padding: 1rem !important;
}

@media (max-width: 768px) {
    body:has(.mining-scene-visual) .max-w-7xl,
    body:has(.mining-scene-visual) .max-w-6xl {
        max-width: 100% !important;
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
}

/* ==========================================================
   "Session in Progress" heading - keep on one line on mobile
========================================================== */

@media (max-width: 480px) {
    h2:has(.blink-dots) {
        font-size: 1.05rem !important;
        white-space: nowrap !important;
        display: flex !important;
        align-items: center !important;
        gap: 4px !important;
    }
}

/* ==========================================================
   "Join Our Community" card was clipping the icon row because
   the card has overflow:hidden. Allow it to show fully and
   pull the row closer to the heading (moves icons up).
========================================================== */

.card-gradient:has(a[title="Telegram"]) {
    overflow: visible !important;
    padding-top: 1rem !important;
    padding-bottom: 1.25rem !important;
}

.card-gradient:has(a[title="Telegram"]) .mb-4 {
    margin-bottom: 0.5rem !important;
}

/* ==========================================================
   Remove bouncing/spinning coin next to "Platinum Network" in header
========================================================== */

[data-testid="layout-logo"] .coin-spin {
    display: none !important;
}

/* ==========================================================
   Remove the bold "Dashboard" page title
========================================================== */

[data-testid="dashboard-title"] {
    display: none !important;
}

/* ==========================================================
   Stats grid (Balance / Level / Daily Reward / Claim Check-in)
   was overflowing off the right edge - grid items don't shrink
   below their content's natural width by default. Force them to.
========================================================== */

.grid:has([data-testid="balance-box"]) {
    max-width: 100%;
}

.grid:has([data-testid="balance-box"]) > * {
    min-width: 0;
}

@media (max-width: 640px) {
    .grid:has([data-testid="balance-box"]) {
        gap: 0.5rem !important;
    }
    .grid:has([data-testid="balance-box"]) .p-6 {
        padding: 0.75rem !important;
    }
    .grid:has([data-testid="balance-box"]) .text-3xl {
        font-size: 1.3rem !important;
    }
    .grid:has([data-testid="balance-box"]) .mb-2 {
        margin-bottom: 0.25rem !important;
    }
}

/* ==========================================================
   Move Dashboard's middle ad to the bottom - pure CSS (flex+order),
   NOT DOM manipulation, so it never fights React's re-renders
   (Dashboard re-renders every second for the countdown timer,
   which previously caused a JS-based move to fight it -> visible
   screen shake/jump).
========================================================== */

/* ==========================================================
   NOTE: Previously tried moving the ad to the bottom via
   display:flex + order on [data-testid="dashboard-page"].
   Reverted once due to shake - but the ad's own layout-shift-on-load
   (fixed now, see adslot fixed-height rule below) was likely the
   real cause. Re-enabling with the fixed-height ad in place.
========================================================== */

[data-testid="dashboard-page"] {
    display: flex !important;
    flex-direction: column !important;
}

[data-testid="adslot-dashboard-middle"] {
    order: 999 !important;
}

/* ==========================================================
   Every direct section of the Dashboard (mining card, stats grid,
   boost row, ad slot, community card) must all share the EXACT
   same width. Previously each had different Tailwind width classes
   (some none, some max-w-4xl, some max-w-7xl) causing visible
   width mismatches between rows. Force uniform width on all of them.
========================================================== */

body:has(.mining-scene-visual) [data-testid="dashboard-page"] > * {
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* ==========================================================
   Adsterra banner (320x50) injected into ad-slot placeholders -
   shrink the container padding, it was sized for the old
   multi-line placeholder text.
========================================================== */

[data-testid^="adslot-"] {
    display: none !important;
}

/* ==========================================================
   fix.css has a "Final Protection" rule at its end that sets
   overflow-x:hidden on .wrapper/.main/.container/.container-fluid
   WITHOUT overflow-y - the same CSS spec quirk that bit #root
   earlier (implicit overflow-y:auto -> nested scroll box if the
   element has any height constraint). This file loads AFTER
   fix.css, so this neutralizes it for good.
========================================================== */

.wrapper, .main, .container, .container-fluid {
    overflow: visible !important;
}

/* ==========================================================
   Mobile bottom nav (data-testid="mobile-nav") is fixed/64px tall
   and sits ON TOP of page content since fixed elements don't take
   up flow space. The last section (social icons / community card)
   was getting hidden behind it. Add bottom breathing room.
========================================================== */

@media (max-width: 767px) {
    [data-testid="dashboard-page"] {
        padding-bottom: 90px !important;
    }
    .card-gradient:has(a[title="Telegram"]) {
        margin-bottom: 20px !important;
    }
}

/* Same fixed-bottom-nav overlap risk exists on every page (Wallet,
   Referrals, Leaderboard, etc), not just Dashboard - add a safe
   universal bottom buffer whenever the mobile nav is present. */
@media (max-width: 767px) {
    body:has([data-testid="mobile-nav"]) {
        padding-bottom: 70px;
    }
}

/* ==========================================================
   Notification dropdown broke because our universal "* { max-width:
   100% }" rule computes 100% relative to its positioned ancestor
   (a small header button), not the viewport - shrinking the intended
   320px (w-80) dropdown down to almost nothing and wrapping the
   "Notifications" text vertically, one syllable per line.
========================================================== */

[data-testid="notification-dropdown"] {
    max-width: min(320px, 92vw) !important;
    width: 320px !important;
}

/* Same bug as the notification dropdown - our universal max-width:100%
   computes against the narrow hamburger button wrapper instead of the
   viewport, breaking the menu down to ~42px and wrapping every word
   vertically, one letter per line. */
#fx-hamburger-menu {
    max-width: min(200px, 80vw) !important;
    width: 200px !important;
}
#fx-hamburger-menu > div {
    max-width: 100% !important;
    white-space: normal !important;
}

/* ==========================================================
   Header icons (Task pill, Profile, Notifications, Logout) are now
   all consolidated inside the hamburger menu next to "Welcome back" -
   hide the old duplicate header buttons. Hiding them doesn't break
   the hamburger menu's Notifications/Logout items, since those work
   by programmatically clicking these elements (which still works
   fine even while hidden).
========================================================== */

[data-testid="header-balance"],
[data-testid="header-profile-btn"],
[data-testid="notification-btn"],
[data-testid="logout-btn"] {
    display: none !important;
}

/* ==========================================================
   All card blocks (Balance, Level, Daily Reward, Claim, Time Boost,
   Boost Mining, mining session card, Community card, etc all use
   .card-gradient) - changed to dark blue background per request.
   Everything else (borders, text, icons) stays as-is.
========================================================== */

.card-gradient {
    background: linear-gradient(135deg, #0b1530 0%, #10204a 100%) !important;
}

/* Time Boost / Boost Earning cards use a different Tailwind gradient
   class (not .card-gradient), so they weren't covered above. */
[data-testid="time-boost-card"],
[data-testid="speed-boost-card"] {
    background: linear-gradient(135deg, #0b1530 0%, #10204a 100%) !important;
}

/* Time Boost / Boost Earning cards use a different Tailwind gradient
   class (bg-gradient-to-br from-blue-500/10...), not .card-gradient,
   so they weren't covered by the rule above. */
[data-testid="time-boost-card"],
[data-testid="speed-boost-card"] {
    background: linear-gradient(135deg, #0b1530 0%, #10204a 100%) !important;
}