/* swspinfix 20261031spin8: hub clip + force-layout without Tailwind;
   Prior spin3: persist shell outside #root + iOS first paint
   Prior spin1: tip/cat hide + sticky stake + scroll unlock at 1280×800.
   SoftAgg untouched. YCC pay overlays preserved (do not hide tip desk rails).
   Rollback: /root/backups/stakewheel-spin4-STAMP/rollback.sh */

/* iOS Safari: NEVER height:auto !important on html — black/blank paint trap */
html.sw-spinfix {
  background: #080B11 !important;
  color-scheme: dark;
  min-height: 100%;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  max-height: none !important;
  overscroll-behavior-y: auto;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}
html.sw-spinfix body {
  background: #080B11 !important;
  min-height: 100%;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  max-height: none !important;
  overscroll-behavior-y: auto;
  touch-action: manipulation;
  /* do NOT set height:auto !important — WebKit SE black screen */
}

html.sw-spinfix body.sw-spinfix-lock {
  overflow: hidden !important;
}

/* First-paint shell — #sw-fp-persist OUTSIDE #root (survives createRoot wipe) */
#sw-fp, #sw-fp-persist {
  box-sizing: border-box;
  min-height: 70vh;
  padding: 20px 16px 32px;
  color: #e2e8f0;
  font: 600 15px/1.45 system-ui, -apple-system, "PingFang TC", "Microsoft JhengHei", sans-serif;
  text-align: center;
  background: #080B11;
}
/* spin6: #sw-fp (inside #root) stays non-blocking; persist MUST take taps */
#sw-fp {
  pointer-events: none;
}
#sw-fp-persist {
  position: relative !important;
  z-index: 80 !important;
  pointer-events: auto !important; /* spin5 set none → chips/tip dead */
}
#sw-fp[data-hide="1"], #sw-fp-persist[data-hide="1"] {
  display: none !important;
}
#sw-fp .sw-fp-title, #sw-fp-persist .sw-fp-title {
  font: 900 22px/1.2 system-ui, sans-serif;
  color: #4ade80;
  margin: 8px 0 6px;
}
#sw-fp .sw-fp-sub, #sw-fp-persist .sw-fp-sub {
  color: #94a3b8;
  font-size: 13px;
  margin: 0 0 18px;
}
#sw-fp .sw-fp-plate, #sw-fp-persist .sw-fp-plate {
  margin: 18px auto;
  width: min(78vw, 280px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 3px solid #f59e0b55;
  background: radial-gradient(circle at 40% 35%, #1e293b, #080B11 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fbbf24;
  font: 800 14px/1.3 system-ui, sans-serif;
  letter-spacing: .04em;
}
#sw-fp .sw-fp-hint, #sw-fp-persist .sw-fp-hint {
  color: #64748b;
  font-size: 12px;
  margin-top: 12px;
}
#sw-fp[data-err="1"] .sw-fp-plate,
#sw-fp-persist[data-err="1"] .sw-fp-plate {
  border-color: #f87171aa;
  color: #fca5a5;
}

/* ===== spin4: wheel + hub-emblem MUST size without Tailwind (media=print fail) ===== */
html.sw-spinfix [data-swl="wheel"],
html.sw-spinfix [data-swl="wheel"].aspect-square {
  --swfly: min(86vw, min(52svh, 340px));
  width: var(--swfly) !important;
  height: var(--swfly) !important;
  max-width: 90vw !important;
  max-height: 56svh !important;
  min-width: 180px !important;
  min-height: 180px !important;
  aspect-ratio: 1 / 1 !important;
  margin: 0 auto !important;
  position: relative !important;
  overflow: hidden !important; /* clip SB emblem — kills huge logo overlay */
  box-sizing: border-box !important;
  flex: 0 0 auto !important;
}
html.sw-spinfix [data-swl="wheel"] > .relative {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
}
html.sw-spinfix [data-testid="wheel-plate"] {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  border-radius: 50% !important;
  transform-origin: center center !important;
}
html.sw-spinfix [data-testid="wheel-plate"] > svg {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
}
/* SB WHEEL hub emblem — absolute + capped (never flood stake/RTP) */
html.sw-spinfix [data-testid="hub-emblem"] {
  position: absolute !important;
  inset: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  pointer-events: none !important;
  z-index: 2 !important;
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  box-sizing: border-box !important;
}
html.sw-spinfix [data-testid="hub-emblem"] > svg {
  width: 42% !important;
  height: 42% !important;
  max-width: 110px !important;
  max-height: 110px !important;
  display: block !important;
}
html.sw-spinfix [data-testid="hub-cap"] {
  width: 80px !important;
  height: 80px !important;
  max-width: 22% !important;
  max-height: 22% !important;
  z-index: 10 !important;
}
/* Never let floated hub cover content as a giant logo */
html.sw-spinfix [data-testid="hub-cap"].swd-hub-float {
  width: 80px !important;
  height: 80px !important;
  max-width: 80px !important;
  max-height: 80px !important;
}

/* Capt. Paws / tip desk — ALWAYS visible; never hide YCC rails */
html.sw-spinfix #swp,
html.sw-spinfix [data-testid="capt-paws"] {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  z-index: 70 !important;
}
html.sw-spinfix #swp.swp-fallback {
  position: fixed !important;
  left: 8px !important;
  bottom: calc(88px + env(safe-area-inset-bottom, 0px)) !important;
  right: auto !important;
  top: auto !important;
  max-width: 88px !important;
}
html.sw-spinfix .swp-tip-box,
html.sw-spinfix [data-swp-tip],
html.sw-spinfix #sw-ycc-pay,
html.sw-spinfix .sw-ycc,
html.sw-spinfix [data-testid="sw-ycc-pay"] {
  visibility: visible !important;
  pointer-events: auto !important;
}

/* Compact / hide bulky tip + cat column on short viewports — NO html.swm required
   Keep YCC tip desk (sw-ycc*) — only hide legacy tip-captain / catcol */
@media (max-height: 950px) {
  html.sw-spinfix [data-testid="tip-captain"],
  html.sw-spinfix [data-testid="tip-reopen"],
  html.sw-spinfix [data-swl="catcol"],
  html.sw-spinfix [data-testid="cat-open"],
  html.sw-spinfix #swl5-pill,
  html.sw-spinfix .swr-coach {
    display: none !important;
  }

  html.sw-spinfix [data-swl="wheel"],
  html.sw-spinfix [data-swl="wheel"].aspect-square,
  html.sw-spinfix [data-testid="wheel-plate"] {
    --swfly: min(78vw, min(42svh, 300px)) !important;
    width: var(--swfly) !important;
    height: var(--swfly) !important;
    max-width: 78vw !important;
    max-height: 42svh !important;
  }

  html.sw-spinfix [data-swl="sec"] {
    display: flex !important;
    flex-direction: column !important;
  }
  html.sw-spinfix [data-swl="sec"] > [data-swl="stage"],
  html.sw-spinfix [data-swl="sec"] > .flex.flex-col {
    order: 4 !important;
  }
  html.sw-spinfix [data-swl="sec"] > #sw-stake,
  html.sw-spinfix [data-swl="sec"] > [data-swl="actions"],
  html.sw-spinfix [data-swl="sec"] > [data-swr="act"],
  html.sw-spinfix [data-swl="sec"] > [data-testid="spin"] {
    order: 5 !important;
  }
  html.sw-spinfix [data-swl="sec"] > [data-swr="fair"],
  html.sw-spinfix [data-swl="sec"] > [data-testid="fair-badge"] {
    order: 20 !important;
  }
  html.sw-spinfix [data-swl="sec"] > [data-swr="hist"],
  html.sw-spinfix [data-swl="sec"] > [data-testid="sw-history"] {
    order: 30 !important;
  }
  html.sw-spinfix [data-swl="sec"] > #swl-cards,
  html.sw-spinfix [data-swl="sec"] > [data-testid="swl-cards"] {
    order: 40 !important;
  }
  html.sw-spinfix main > aside,
  html.sw-spinfix [data-swl="aside"] {
    order: 50 !important;
  }

  html.sw-spinfix body #root #sw-stake,
  html.sw-spinfix body #root [data-swl="actions"],
  html.sw-spinfix body #root [data-swr="act"] {
    position: sticky !important;
    bottom: 0 !important;
    top: auto !important;
    z-index: 60 !important;
    background: linear-gradient(180deg, rgba(8,11,17,0), #080B11 18%) #080B11 !important;
    padding-top: 10px !important;
    padding-bottom: max(10px, env(safe-area-inset-bottom, 0px)) !important;
    margin-bottom: 0 !important;
    box-shadow: 0 -8px 24px rgba(0,0,0,.35);
  }

  html.sw-spinfix [data-testid="demo-banner"],
  html.sw-spinfix #swm-banner-fix {
    font-size: 12px !important;
    line-height: 1.3 !important;
    padding: 6px 10px !important;
    margin: 0 0 4px !important;
    max-height: 3.2em;
    overflow: hidden;
  }
}

@media (min-width: 1024px) and (max-height: 950px) {
  html.sw-spinfix [data-swl="sec"] {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 340px) !important;
    column-gap: 16px !important;
    row-gap: 6px !important;
    align-items: end !important;
  }
  html.sw-spinfix [data-swl="sec"] > * {
    grid-column: 1 / -1;
  }
  html.sw-spinfix [data-swl="sec"] > [data-swl="stage"],
  html.sw-spinfix [data-swl="sec"] > .flex.flex-col {
    grid-column: 1 !important;
    grid-row: 4 !important;
    order: 0 !important;
  }
  html.sw-spinfix body #root #sw-stake,
  html.sw-spinfix body #root [data-swl="actions"],
  html.sw-spinfix body #root [data-swr="act"] {
    grid-column: 2 !important;
    grid-row: 4 !important;
    order: 0 !important;
    align-self: end !important;
    position: sticky !important;
    bottom: 8px !important;
    box-shadow: none;
  }
}

@media (max-height: 800px) {
  html.sw-spinfix [data-swl="wheel"],
  html.sw-spinfix [data-swl="wheel"].aspect-square {
    --swfly: min(72vw, min(36svh, 260px)) !important;
    width: var(--swfly) !important;
    height: var(--swfly) !important;
    max-height: 36svh !important;
  }
  html.sw-spinfix .swr-head,
  html.sw-spinfix [data-swl="header"] {
    padding-top: 2px !important;
    padding-bottom: 2px !important;
  }
  html.sw-spinfix .swr-title {
    display: none !important;
  }
}

@media (min-width: 1100px) and (max-height: 950px) {
  html.sw-spinfix #sav-left {
    max-height: 100svh !important;
    overflow-y: auto !important;
  }
  html.sw-spinfix #sav-left #sav-live {
    font-size: 11px !important;
    opacity: 0.85;
  }
}

html.sw-spinfix [role="dialog"][aria-modal="true"].fixed.inset-0 {
  pointer-events: auto;
  overscroll-behavior: contain;
}

/* Belt: keep countdown toast above sticky stake / YCC chrome */
html.sw-spinfix #swer-cd-fixed.on {
  display: block !important;
  z-index: 2147483000 !important;
}

/* Chips must stay tappable */
html.sw-spinfix .swr-chip,
html.sw-spinfix button.swr-chip,
html.sw-spinfix [data-testid^="chip-"] {
  pointer-events: auto !important;
  position: relative;
  z-index: 61;
}


/* ===== spin5: persist chips + Capt tip never clipped ===== */
html.sw-spinfix #sw-fp-persist .sw-fp-chips{display:flex!important;visibility:visible!important}
html.sw-spinfix #sw-fp-persist .sw-fp-chip,
html.sw-spinfix #sw-fp-persist .sw-fp-stake,
html.sw-spinfix #sw-fp-persist .sw-fp-tip{
  pointer-events:auto!important;
  visibility:visible!important;
  opacity:1!important;
}
html.sw-spinfix #swp.swp-fallback,
html.sw-spinfix #swp[data-testid="capt-paws"].swp-fallback{
  position:fixed!important;
  left:10px!important;
  bottom:calc(96px + env(safe-area-inset-bottom,0px))!important;
  right:auto!important;
  top:auto!important;
  z-index:2147482500!important;
  max-width:110px!important;
  display:flex!important;
  visibility:visible!important;
  opacity:1!important;
  pointer-events:none!important;
}
html.sw-spinfix #swp.swp-fallback img,
html.sw-spinfix #swp.swp-fallback .swp-tip,
html.sw-spinfix #swp.swp-fallback .swp-b{
  pointer-events:auto!important;
}
html.sw-spinfix #swp.swp-fallback .swp-tip-box{
  display:flex!important; /* spin5: tip amounts visible by default on fallback */
  left:64px!important;
  bottom:0!important;
  min-width:168px!important;
  z-index:2147482501!important;
}
html.sw-spinfix #swp.swp-fallback .swp-tip:not(.open) .swp-tip-box{
  display:flex!important;
}
/* tip desk modal above wallet banner */
html.sw-spinfix #sw-ycc-pay,
html.sw-spinfix #sw-ycc-pay-dlg,
html.sw-spinfix .sw-ycc-dlg,
html.sw-spinfix [data-testid="sw-ycc-pay"]{
  z-index:2147483001!important;
}


/* ===== spin6: interactions + tip desk + no black-tab steal ===== */
html.sw-spinfix #sw-fp-persist{
  pointer-events:auto!important;
  z-index:80!important;
  position:relative!important;
}
html.sw-spinfix #sw-fp-persist .sw-fp-chip,
html.sw-spinfix #sw-fp-persist .sw-fp-stake,
html.sw-spinfix #sw-fp-persist .sw-fp-tip,
html.sw-spinfix #sw-fp-persist .sw-fp-tipdesk,
html.sw-spinfix #sw-fp-persist .sw-fp-tipdesk button{
  pointer-events:auto!important;
  cursor:pointer!important;
  -webkit-tap-highlight-color:transparent;
  touch-action:manipulation;
}
/* Until React chips+wheel exist, #root must not steal hits / blank the tab */
html.sw-spinfix body:not(.sw-react-ready) #root{
  pointer-events:none!important;
}
html.sw-spinfix body.sw-react-ready #root{
  pointer-events:auto;
}
/* Local amber countdown toast (works without swer/React) */
#sw-fp-cd, #swer-cd-fixed{
  /* keep swer toast; local mirrors */
}
#sw-fp-cd{
  display:none; position:fixed; z-index:2147483100;
  left:50%; top:14%; transform:translateX(-50%);
  width:min(300px,90vw); pointer-events:none;
}
#sw-fp-cd.on{ display:block!important; visibility:visible!important; opacity:1!important; }
#sw-fp-cd .sw-fp-cd-inner{
  display:flex; flex-direction:column; align-items:center; gap:4px;
  padding:16px 18px 14px; border-radius:18px;
  background:rgba(8,14,22,.94); border:2px solid #f59e0b;
  box-shadow:0 12px 40px rgba(0,0,0,.55), 0 0 0 1px rgba(245,158,11,.25);
  color:#f8fafc; font:700 13px/1.25 system-ui,-apple-system,"PingFang TC","Microsoft JhengHei",sans-serif;
}
#sw-fp-cd .sw-fp-cd-n{
  font:900 42px/1 system-ui,sans-serif; color:#fde68a;
  text-shadow:0 0 14px rgba(245,158,11,.7); font-variant-numeric:tabular-nums;
}
#sw-fp-cd .sw-fp-cd-l{ font:800 11px/1 system-ui,sans-serif; letter-spacing:.08em; color:#fbbf24; text-transform:uppercase; }
#sw-fp-cd .sw-fp-cd-h{ font:600 11px/1.3 system-ui,sans-serif; color:#94a3b8; }
/* Inline tip desk under Tip button */
#sw-fp-tipdesk{
  display:none; margin:8px auto 0; max-width:min(340px,94vw);
  padding:12px 12px 10px; border-radius:14px;
  background:#121826; border:1px solid #f59e0b88;
  box-shadow:0 8px 24px #000a; text-align:center;
  pointer-events:auto!important; z-index:90; position:relative;
}
#sw-fp-tipdesk.open{ display:block!important; }
#sw-fp-tipdesk .sw-fp-td-title{ font:800 12px/1.2 system-ui,sans-serif; color:#fcd34d; margin:0 0 8px; }
#sw-fp-tipdesk .sw-fp-td-row{ display:flex; flex-wrap:wrap; gap:8px; justify-content:center; margin:0 0 8px; }
#sw-fp-tipdesk .sw-fp-td-amt{
  appearance:none; min-width:56px; min-height:40px; padding:8px 12px; border-radius:999px;
  border:2px solid #f59e0b; background:#1d2433; color:#fde68a;
  font:800 14px/1 system-ui,sans-serif; cursor:pointer;
}
#sw-fp-tipdesk .sw-fp-td-note{ color:#94a3b8; font:500 11px/1.35 system-ui,sans-serif; margin:0; }
/* Capt tip-box: don't cover center chips; keep left, capped */
html.sw-spinfix #swp.swp-fallback .swp-tip-box{
  max-width:200px!important;
  max-height:42vh!important;
  overflow:auto!important;
}

/* spin7-topmost: persist above any late overlays while React gated */
html.sw-spinfix #sw-fp-persist{
  pointer-events:auto!important;
  z-index:2147483000!important;
  position:relative!important;
  isolation:isolate;
}
html.sw-spinfix body:not(.sw-react-ready) #root{
  pointer-events:none!important;
}
html.sw-spinfix #sw-fp-cd.on{display:block!important;z-index:2147483646!important}
html.sw-spinfix #sw-fp-tipdesk.open{display:block!important}
html.sw-spinfix #sw-fp-toast.on{display:block!important;z-index:2147483647!important}
