/* CashBubble wallet and history: presentation only.
   Keep this scoped to the two existing data-screen values. The application
   continues to own all balances, history rows, IDs and action handlers. */

body[data-theme="bubble"] #modalBackdrop:is([data-screen="wallet"],[data-screen="history"]){
  --wallet-panel:#10141f;
  --wallet-card:#1b1e29;
  --wallet-line:#49336b;
  --wallet-text:#eeeefa;
  --wallet-muted:#b6b8d2;
  --wallet-accent:#00d7ae;
  --wallet-gap-top:max(16px,env(safe-area-inset-top));
  --wallet-gap-bottom:max(16px,env(safe-area-inset-bottom));
  box-sizing:border-box;
  align-items:center!important;
  justify-content:center!important;
  padding:var(--wallet-gap-top) max(16px,env(safe-area-inset-right)) var(--wallet-gap-bottom) max(16px,env(safe-area-inset-left))!important;
  overflow:hidden;
  background:#090716c7!important;
  backdrop-filter:blur(8px);
  -webkit-backdrop-filter:blur(8px);
}

body[data-theme="bubble"] #modalBackdrop:is([data-screen="wallet"],[data-screen="history"]) *,
body[data-theme="bubble"] #modalBackdrop:is([data-screen="wallet"],[data-screen="history"]) *::before,
body[data-theme="bubble"] #modalBackdrop:is([data-screen="wallet"],[data-screen="history"]) *::after{
  box-sizing:border-box;
}

body[data-theme="bubble"] #modalBackdrop:is([data-screen="wallet"],[data-screen="history"]) .campaign-modal{
  position:relative!important;
  display:flex!important;
  flex-direction:column!important;
  width:min(640px,100%)!important;
  min-width:0!important;
  min-height:0!important;
  max-height:calc(100vh - var(--wallet-gap-top) - var(--wallet-gap-bottom))!important;
  max-height:calc(100dvh - var(--wallet-gap-top) - var(--wallet-gap-bottom))!important;
  margin:0!important;
  padding:0!important;
  overflow:hidden!important;
  border:1px solid var(--wallet-line)!important;
  border-radius:26px!important;
  background:var(--wallet-panel)!important;
  box-shadow:0 26px 75px #05020db3,0 0 42px #6c39b51f!important;
  color:var(--wallet-text);
  font-family:Inter,ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif;
}

/* Only the content scrolls. The close control stays in the modal's top-right. */
body[data-theme="bubble"] #modalBackdrop:is([data-screen="wallet"],[data-screen="history"]) #modalContent{
  flex:1 1 auto;
  min-width:0!important;
  min-height:0!important;
  max-height:none!important;
  width:100%;
  padding:0!important;
  overflow-x:hidden!important;
  overflow-y:auto!important;
  overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
  scrollbar-width:thin;
  scrollbar-color:#796294 var(--wallet-panel);
  color:var(--wallet-text);
  font-size:14px;
  line-height:1.5;
}

body[data-theme="bubble"] #modalBackdrop:is([data-screen="wallet"],[data-screen="history"]) #modalContent::-webkit-scrollbar{
  width:6px;
  height:6px;
}

body[data-theme="bubble"] #modalBackdrop:is([data-screen="wallet"],[data-screen="history"]) #modalContent::-webkit-scrollbar-thumb{
  border-radius:999px;
  background:#796294;
}

body[data-theme="bubble"] #modalBackdrop:is([data-screen="wallet"],[data-screen="history"]) #modalContent::-webkit-scrollbar-thumb:hover{
  background:#a58dc1;
}

body[data-theme="bubble"] #modalBackdrop:is([data-screen="wallet"],[data-screen="history"]) .modal-close{
  position:absolute!important;
  z-index:35!important;
  float:none!important;
  top:18px!important;
  right:18px!important;
  bottom:auto!important;
  left:auto!important;
  display:grid!important;
  place-items:center;
  width:44px!important;
  height:44px!important;
  min-width:44px;
  min-height:44px;
  margin:0!important;
  padding:0!important;
  border:1px solid #775198!important;
  border-radius:50%!important;
  background:#35214e!important;
  color:#fff!important;
  box-shadow:none!important;
  cursor:pointer;
  touch-action:manipulation;
  transform:none!important;
}

body[data-theme="bubble"] #modalBackdrop:is([data-screen="wallet"],[data-screen="history"]) .modal-close:hover{
  border-color:#a77bdb!important;
  background:#4a2e69!important;
}

body[data-theme="bubble"] #modalBackdrop:is([data-screen="wallet"],[data-screen="history"]) .modal-close .ui-icon{
  width:22px;
  height:22px;
}

body[data-theme="bubble"] #modalBackdrop:is([data-screen="wallet"],[data-screen="history"]) button:focus-visible{
  outline:3px solid var(--wallet-accent)!important;
  outline-offset:3px!important;
}

/* Reserve the same close-button area for the loading and error states. */
body[data-theme="bubble"] #modalBackdrop:is([data-screen="wallet"],[data-screen="history"]) #modalContent>p{
  min-height:100px;
  margin:0;
  padding:28px 86px 28px 24px;
  color:var(--wallet-muted)!important;
  overflow-wrap:anywhere;
}

body[data-theme="bubble"] #modalBackdrop[data-screen="wallet"] #modalContent>.modal-head,
body[data-theme="bubble"] #modalBackdrop[data-screen="history"] .history-reference-head{
  position:sticky;
  z-index:3;
  top:0;
  min-width:0;
  min-height:90px;
  margin:0!important;
  padding:22px 86px 22px 24px!important;
  border:0;
  border-bottom:1px solid var(--wallet-line);
  border-radius:0;
  background:linear-gradient(110deg,#24133b,#171327)!important;
  color:var(--wallet-text);
}

body[data-theme="bubble"] #modalBackdrop[data-screen="wallet"] #modalContent>.modal-head{
  display:grid;
  grid-template-columns:44px minmax(0,1fr);
  align-items:center;
  column-gap:13px;
  row-gap:5px;
}

body[data-theme="bubble"] #modalBackdrop[data-screen="wallet"] .modal-head .modal-icon,
body[data-theme="bubble"] #modalBackdrop[data-screen="history"] .history-reference-title>span{
  display:grid;
  place-items:center;
  flex:0 0 44px;
  width:44px!important;
  height:44px!important;
  margin:0;
  border:1px solid #126b64;
  border-radius:14px;
  background:#10383b;
  color:var(--wallet-accent);
}

body[data-theme="bubble"] #modalBackdrop[data-screen="wallet"] .modal-icon .ui-icon,
body[data-theme="bubble"] #modalBackdrop[data-screen="history"] .history-reference-title .ui-icon{
  width:24px;
  height:24px;
}

body[data-theme="bubble"] #modalBackdrop[data-screen="wallet"] .modal-head h2,
body[data-theme="bubble"] #modalBackdrop[data-screen="history"] .history-reference-title strong{
  min-width:0;
  margin:0!important;
  color:var(--wallet-text);
  font-size:24px!important;
  font-weight:800;
  line-height:1.2;
  overflow-wrap:anywhere;
}

body[data-theme="bubble"] #modalBackdrop[data-screen="wallet"] .modal-head p{
  grid-column:1/-1;
  margin:8px 0 0!important;
  color:var(--wallet-muted);
  font-size:14px!important;
  font-weight:400;
  line-height:1.5;
}

body[data-theme="bubble"] #modalBackdrop[data-screen="wallet"] .player-wallet{
  display:grid;
  gap:18px;
  width:100%;
  min-width:0!important;
  padding:24px;
}

body[data-theme="bubble"] #modalBackdrop[data-screen="wallet"] .wallet-total{
  min-width:0;
  min-height:150px;
  justify-content:center;
  gap:5px;
  padding:24px 18px;
  border:1px solid #216c69;
  border-radius:20px;
  background:radial-gradient(ellipse at 50% 0,#00d7ae16,transparent 80%),#17232d;
  text-align:center;
}

body[data-theme="bubble"] #modalBackdrop[data-screen="wallet"] :is(.wallet-total,.affiliate-wallet-highlight) small{
  color:#b9c8de;
  font-size:12px;
  font-weight:800;
  line-height:1.5;
  letter-spacing:.07em;
}

body[data-theme="bubble"] #modalBackdrop[data-screen="wallet"] :is(.wallet-total,.affiliate-wallet-highlight) strong{
  max-width:100%;
  margin:3px 0;
  color:#57efc2;
  font-size:clamp(28px,6vw,38px);
  font-weight:800;
  line-height:1.25;
  font-variant-numeric:tabular-nums;
  overflow-wrap:anywhere;
}

body[data-theme="bubble"] #modalBackdrop[data-screen="wallet"] :is(.wallet-total,.affiliate-wallet-highlight) span{
  color:var(--wallet-muted);
  font-size:13px;
  line-height:1.5;
}

body[data-theme="bubble"] #modalBackdrop[data-screen="wallet"] .affiliate-wallet-highlight{
  min-width:0;
  gap:7px;
  margin:0;
  padding:20px;
  border:1px solid var(--wallet-line);
  border-radius:20px;
  background:#1d1730;
}

body[data-theme="bubble"] #modalBackdrop[data-screen="wallet"] .affiliate-wallet-highlight strong{
  font-size:30px;
}

body[data-theme="bubble"] #modalBackdrop[data-screen="wallet"] .wallet-actions{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:10px;
  min-width:0;
  margin:0;
}

body[data-theme="bubble"] #modalBackdrop[data-screen="wallet"] :is(.wallet-actions,.affiliate-wallet-highlight) button{
  display:flex;
  align-items:center;
  justify-content:center;
  width:100%;
  min-width:0;
  min-height:50px;
  height:auto;
  padding:13px 10px;
  border:1px solid #655087;
  border-radius:15px;
  background:#2a2040;
  color:var(--wallet-text);
  box-shadow:none;
  font-family:inherit;
  font-size:12px!important;
  font-weight:800;
  line-height:1.45;
  text-align:center;
  white-space:normal;
  overflow-wrap:anywhere;
  cursor:pointer;
  touch-action:manipulation;
}

body[data-theme="bubble"] #modalBackdrop[data-screen="wallet"] :is(.wallet-actions,.affiliate-wallet-highlight) .orange-button{
  border-color:#00d7ae!important;
  background:linear-gradient(105deg,#00d7ae,#2bea8a)!important;
  color:#062b25!important;
}

body[data-theme="bubble"] #modalBackdrop[data-screen="wallet"] :is(.wallet-actions,.affiliate-wallet-highlight) button:hover{
  border-color:#aa8bd1;
  filter:brightness(1.08);
}

body[data-theme="bubble"] #modalBackdrop[data-screen="history"] .history-reference{
  width:100%;
  min-width:0;
  color:var(--wallet-text);
  background:var(--wallet-panel);
}

body[data-theme="bubble"] #modalBackdrop[data-screen="history"] .history-reference-head{
  display:flex;
  justify-content:flex-start;
  align-items:center;
}

body[data-theme="bubble"] #modalBackdrop[data-screen="history"] .history-reference-title{
  display:flex;
  align-items:center;
  gap:13px;
  min-width:0;
}

body[data-theme="bubble"] #modalBackdrop[data-screen="history"] .history-reference-body{
  min-width:0;
  padding:24px;
}

body[data-theme="bubble"] #modalBackdrop[data-screen="history"] .history-reference-intro{
  align-items:flex-start;
  gap:10px;
  margin:0 0 20px;
  color:var(--wallet-muted);
  font-size:14px;
  line-height:1.6;
}

body[data-theme="bubble"] #modalBackdrop[data-screen="history"] .history-reference-intro>span{
  flex:0 0 22px;
  padding-top:1px;
  color:var(--wallet-accent);
}

body[data-theme="bubble"] #modalBackdrop[data-screen="history"] .history-reference-intro .ui-icon{
  width:22px;
  height:22px;
}

body[data-theme="bubble"] #modalBackdrop[data-screen="history"] .history-reference-table{
  width:100%;
  min-width:0;
  overflow:hidden;
  border:1px solid var(--wallet-line);
  border-radius:17px;
  background:var(--wallet-card);
}

/* Keep the native table and its complete financial values, even on narrow screens. */
body[data-theme="bubble"] #modalBackdrop[data-screen="history"] .history-reference-table table{
  width:100%;
  min-width:0;
  table-layout:fixed;
  border-collapse:collapse;
  font-variant-numeric:tabular-nums;
}

body[data-theme="bubble"] #modalBackdrop[data-screen="history"] .history-reference-table thead{
  background:#261d39;
}

body[data-theme="bubble"] #modalBackdrop[data-screen="history"] .history-reference-table :is(th,td){
  padding:14px 13px;
  color:var(--wallet-text);
  font-size:14px;
  line-height:1.55;
  vertical-align:top;
  white-space:normal;
  overflow-wrap:anywhere;
}

body[data-theme="bubble"] #modalBackdrop[data-screen="history"] .history-reference-table th{
  color:#c8bce0;
  font-size:12px;
  font-weight:800;
  text-align:left;
}

body[data-theme="bubble"] #modalBackdrop[data-screen="history"] .history-reference-table th:first-child{width:40%}
body[data-theme="bubble"] #modalBackdrop[data-screen="history"] .history-reference-table th:nth-child(2){width:27%}
body[data-theme="bubble"] #modalBackdrop[data-screen="history"] .history-reference-table th:last-child{width:33%;text-align:right}

body[data-theme="bubble"] #modalBackdrop[data-screen="history"] .history-reference-table th span{
  color:#bb9ae6;
}

body[data-theme="bubble"] #modalBackdrop[data-screen="history"] .history-reference-table td{
  border-top:1px solid #443454;
}

body[data-theme="bubble"] #modalBackdrop[data-screen="history"] .history-reference-table tbody tr:nth-child(even){
  background:#ffffff03;
}

body[data-theme="bubble"] #modalBackdrop[data-screen="history"] .history-reference-table td.credit{
  color:#57efb0;
  font-weight:800;
}

body[data-theme="bubble"] #modalBackdrop[data-screen="history"] .history-reference-table td.debit{
  color:#ff8daf;
  font-weight:800;
}

body[data-theme="bubble"] #modalBackdrop[data-screen="history"] .history-reference-table .history-empty td{
  padding:28px 16px!important;
  color:var(--wallet-muted)!important;
  line-height:1.6;
}

body[data-theme="bubble"] #modalBackdrop[data-screen="history"] .history-reference-table .history-empty span{
  color:var(--wallet-accent);
}

@media(max-width:600px){
  body[data-theme="bubble"] #modalBackdrop:is([data-screen="wallet"],[data-screen="history"]){
    --wallet-gap-top:max(10px,env(safe-area-inset-top));
    --wallet-gap-bottom:max(10px,env(safe-area-inset-bottom));
    padding-right:max(10px,env(safe-area-inset-right))!important;
    padding-left:max(10px,env(safe-area-inset-left))!important;
  }

  body[data-theme="bubble"] #modalBackdrop:is([data-screen="wallet"],[data-screen="history"]) .campaign-modal{
    border-radius:22px!important;
  }

  body[data-theme="bubble"] #modalBackdrop:is([data-screen="wallet"],[data-screen="history"]) .modal-close{
    top:14px!important;
    right:14px!important;
  }

  body[data-theme="bubble"] #modalBackdrop[data-screen="wallet"] #modalContent>.modal-head,
  body[data-theme="bubble"] #modalBackdrop[data-screen="history"] .history-reference-head{
    min-height:82px;
    padding:18px 74px 18px 16px!important;
  }

  body[data-theme="bubble"] #modalBackdrop[data-screen="wallet"] .modal-head h2,
  body[data-theme="bubble"] #modalBackdrop[data-screen="history"] .history-reference-title strong{
    font-size:22px!important;
  }

  body[data-theme="bubble"] #modalBackdrop[data-screen="wallet"] .player-wallet,
  body[data-theme="bubble"] #modalBackdrop[data-screen="history"] .history-reference-body{
    padding:18px 16px;
  }

  body[data-theme="bubble"] #modalBackdrop[data-screen="wallet"] .wallet-actions{
    grid-template-columns:1fr;
  }

  body[data-theme="bubble"] #modalBackdrop[data-screen="wallet"] .wallet-total{
    min-height:140px;
    padding:22px 14px;
  }

  body[data-theme="bubble"] #modalBackdrop[data-screen="wallet"] .affiliate-wallet-highlight{
    padding:18px 14px;
  }

  body[data-theme="bubble"] #modalBackdrop[data-screen="history"] .history-reference-table :is(th,td){
    padding:12px 9px;
    font-size:13px;
  }

  body[data-theme="bubble"] #modalBackdrop[data-screen="history"] .history-reference-table th{
    font-size:12px;
  }
}

@media(max-width:360px){
  body[data-theme="bubble"] #modalBackdrop[data-screen="history"] .history-reference-table :is(th,td){
    padding-right:7px;
    padding-left:7px;
    font-size:12px;
  }
}

/* A short landscape viewport must still leave room for scrollable content. */
@media(max-height:420px){
  body[data-theme="bubble"] #modalBackdrop[data-screen="wallet"] .player-wallet,
  body[data-theme="bubble"] #modalBackdrop[data-screen="history"] .history-reference-body{
    padding-top:16px;
    padding-bottom:16px;
  }
}
