/* Perks (AC93 privilege cards, AC94 growth funds): perks-ui.js, docs/PERKS.md.
   A fixed-height standalone screen: tab strip, one tab body, and the bottom bar with Back on the left and
   Claim all on the right. Only the Cards tab's card list scrolls (AC796); the fund tabs never scroll. */

/* Screen shell */
#online.perks-view #content{display:flex;flex-direction:column;min-height:0}
.perks-panel{display:flex;flex-direction:column;gap:8px;flex:1 1 auto;min-height:0;margin:0;padding:10px;overflow:hidden}
.perks-tabs{flex:none}
#online .perks-tabs .secondary{min-height:var(--tier-dense-h);font-size:18px;padding:5px 2px}
.perks-body{display:flex;flex-direction:column;gap:8px;flex:1 1 auto;min-height:0}
.perks-head{position:relative;display:flex;align-items:center;justify-content:center;min-height:40px;flex:none}
#online .perks-head h1{margin:0;color:#324052;font:28px/1.1 Lucky}
.perks-head .help-button{position:absolute;right:0;top:50%;translate:0 -50%}

/* Shared bits */
.perk-gem{display:inline-flex;align-items:center;gap:4px;font:22px/1 Lucky;color:var(--cream-200);-webkit-text-stroke:1.5px #2b2238;paint-order:stroke fill}
.perk-gem img{width:22px;height:22px;object-fit:contain}
.perk-status{display:inline-flex;align-items:center;min-height:22px;padding:2px 10px;border-radius:10px 10px 10px 2px;background:#6c6680;color:#f4efe2;font:800 12px/1 system-ui;letter-spacing:.02em}
.perk-status.is-on{background:#2f8a4c;color:#fff}
/* AC104 (build 52, ASC AATWtNu_i8u5Z1j0sAfITqw): one polished "Coming soon" lock.
   The pill is a muted plump chip (top highlight, darker lip) and the padlock a small
   gold body with a keyhole under a steel shackle; the fund tile badge draws the same
   padlock on a round dark badge. CSS only, no new art. */
.perk-lock{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:40px;box-sizing:border-box;padding:4px 16px 5px 13px;border:2px solid #4b4560;border-radius:14px;background:linear-gradient(#f1edf7,#d3cce2);box-shadow:inset 0 2px #ffffffb3,inset 0 -3px #b9b0cc,0 3px #2e2940;color:#463f5c;font:18px/1 Lucky;white-space:nowrap}
.perk-lock i,.fund-tile-lock{--lock-w:15px;--lock-h:12px}
.perk-lock i{position:relative;flex:none;width:var(--lock-w);height:calc(var(--lock-h) + 7px);margin-top:-1px}
.perk-lock i:before,.fund-tile-lock:before{content:"";position:absolute;left:50%;bottom:calc(var(--lock-h) - 3px);width:calc(var(--lock-w) - 6px);height:8px;margin-left:calc((var(--lock-w) - 6px) / -2);box-sizing:border-box;border:2.5px solid #8a85a0;border-bottom:0;border-radius:6px 6px 0 0}
.perk-lock i:after,.fund-tile-lock:after{content:"";position:absolute;left:50%;bottom:0;width:var(--lock-w);height:var(--lock-h);margin-left:calc(var(--lock-w) / -2);box-sizing:border-box;border:1.5px solid #5a3a1c;border-radius:3.5px;background:radial-gradient(circle at 50% 40%,#5a3a1c 0 1.7px,transparent 2.1px),linear-gradient(#5a3a1c,#5a3a1c) 50% 70%/1.6px 4px no-repeat,linear-gradient(var(--honey-200),#f2b23a 60%,#d98f22);box-shadow:inset 0 1px var(--gold-50)}
.perk-claimed{display:flex;flex-direction:column;align-items:center;gap:2px;min-width:0;text-align:center}
.perk-claimed b{color:#2f7a45;font:18px/1 Lucky}
.perk-claimed small{color:#7b6550;font:700 11px/1.2 system-ui;white-space:nowrap}
#online .perk-claim{min-width:104px;min-height:var(--tier-full-h);margin:0;padding:6px 12px;font-size:var(--tier-full-fs)}
#online .perk-claim.is-ready:not(:disabled){--small-top:var(--btn-claim-top);--small-bottom:var(--btn-claim-bottom);--small-edge:var(--btn-claim-edge);--small-lip:var(--btn-claim-lip);--small-shine:var(--btn-claim-shine)}

/* Daily Benefits */
.perk-daily{display:grid;grid-template-columns:62px minmax(0,1fr) auto;align-items:center;gap:10px;flex:none;min-height:78px;padding:8px 10px;border:3px solid #1d3a63;border-radius:16px;background:linear-gradient(#4b8fd8,#2f6fb8);box-shadow:inset 0 2px #ffffff55,0 3px #172b48}
.perk-gem-tile{position:relative;display:grid;place-items:center;width:58px;height:58px;border:2px solid #6a4a20;border-radius:var(--vs-radius);background:linear-gradient(#e7b56b,#c4823c);box-shadow:inset 0 2px #fff5,0 2px #4a3016}
.perk-gem-tile img{width:38px;height:38px;object-fit:contain}
.perk-gem-tile b{position:absolute;right:3px;bottom:0;color:#fff;font:15px/1 Lucky;-webkit-text-stroke:2px #2b2238;paint-order:stroke fill}
.perk-daily-copy{min-width:0}
#online .perk-daily h2{margin:0;color:#fff;font:22px/1.1 Lucky;-webkit-text-stroke:1.5px #17304f;paint-order:stroke fill}
.perk-daily-copy small{color:#dcecff;font:700 12px/1.3 system-ui}
.perk-daily .perk-claimed b{color:#d8ffcf;-webkit-text-stroke:1px #17304f;paint-order:stroke fill}
.perk-daily .perk-claimed small{color:#e6f1ff}

/* Paid cards */
.perk-card{position:relative;display:grid;grid-template-rows:auto minmax(0,1fr);gap:4px;flex:1 1 0;min-height:0;padding:22px 10px 8px;border:3px solid #1e2c4a;border-radius:16px;box-shadow:inset 0 2px #ffffff40,0 3px var(--ink-navy);overflow:hidden;container-type:size}
.perk-card.is-adfree{background:linear-gradient(135deg,#3e86cf,#2a5ea6)}
.perk-card.is-monthly{background:linear-gradient(135deg,#8a55d6,#5d35a8)}
.perk-card .perk-status{position:absolute;left:0;top:0;border-radius:0 0 12px 0;min-height:20px}
.perk-card-head{display:flex;align-items:baseline;gap:8px;min-width:0;margin-top:2px}
#online .perk-card h2{margin:0;color:#fff;font:23px/1.05 Lucky;-webkit-text-stroke:1.5px var(--ink-navy);paint-order:stroke fill;white-space:nowrap}
.perk-term{margin-left:auto;padding:2px 8px;border-radius:9px;background:#1b2238aa;color:var(--gold-100);font:800 11px/1.3 system-ui;white-space:nowrap}
.perk-card-main{display:grid;grid-template-columns:minmax(0,1fr) 134px;align-items:center;gap:8px;min-height:0}
.perk-card-aside{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;min-height:0;height:100%}
/* AC852 (build 194, owner: "Nie podoba mi się, że tekst nie jest w linii"): a card's benefit rows share one icon
   column, as wide as the card's widest mark (the AUTO or AD chip), so every row's text starts on the same line. The
   rows are subgrids of the list; an icon narrower than the column is centred in it. */
.perk-benefits{display:grid;grid-template-columns:auto minmax(0,1fr);gap:4px 0;margin:0;padding:0;list-style:none;min-width:0}
.perk-benefits li{display:grid;grid-template-columns:subgrid;grid-column:1/-1;align-items:center;column-gap:6px;min-height:24px;padding:2px 6px;border-radius:8px;background:#14193066;color:#fff;font:800 13px/1.15 system-ui}
.perk-benefit-icon{display:grid;place-items:center;min-width:20px;height:20px}
.perk-benefit-icon img{width:20px;height:20px;object-fit:contain}
.perk-benefit-icon>.perk-cap-mark{width:18px;height:18px}
/* AC168: let the longer ad benefit wrap under its icon inside the same pill. */
.perk-card.is-monthly .perk-benefits li:nth-child(2){display:flow-root}
.perk-card.is-monthly .perk-benefits li:nth-child(2) .perk-benefit-icon{float:left;margin-right:6px}
/* AC200: the named chests need room in the active native card's compact column.
   Tighten only its benefit pill spacing; retain text tiers, art and actions. */
@container(max-height:170px){
 #online .perk-card.is-monthly.is-active:has(.store-buy) .perk-benefits{gap:1px}
 #online .perk-card.is-monthly.is-active:has(.store-buy) .perk-benefits li{min-height:20px;padding:0 4px}
 #online .perk-card.is-monthly.is-active:has(.store-buy) .perk-benefits li:nth-child(2){padding-block:0;line-height:1.08}
 #online .perk-card.is-monthly.is-active:has(.store-buy) .perk-card-main{column-gap:0}
 #online .perk-card.is-monthly.is-active:has(.store-buy) .perk-benefits li:nth-child(2) .perk-benefit-icon{margin-right:0}
}
html[lang="pl"] .perk-card.is-monthly .perk-card-main{grid-template-columns:minmax(0,1fr) 124px}
html[lang="pl"] .perk-card.is-monthly .perk-benefits li:nth-child(2) .perk-benefit-icon{margin-right:4px}
@media(min-height:731px){
 html[lang="pl"] .perk-card.is-monthly{padding-top:19px;padding-bottom:4px;gap:1px}
 html[lang="pl"] .perk-card.is-monthly .perk-benefits{gap:2px}
}
.perk-ad-mark{padding:1px 3px;border:1.5px solid #3b1f14;border-radius:5px;background:var(--gold-50);color:#3b1f14;font:900 9px/1 system-ui}
.perk-speed-mark{color:#ffe36b;font:900 20px/1 system-ui}
.perk-card-art{display:grid;place-items:center;flex:1 1 0;min-height:0;width:100%;overflow:hidden}
.perk-card-art img{width:100%;height:100%;max-height:78px;min-height:0;object-fit:contain;filter:drop-shadow(0 2px 2px #0006)}
.perk-card-action{display:flex;justify-content:center;align-items:center;flex:none;width:100%;min-height:44px}
/* AC184: raise only the existing bottom-right native price. */
#online .perk-card-action .store-buy{translate:0 -4px}
/* Keep AC184's lower header inside the same cards when browser chrome leaves
   less room: reuse Compact benefit type, tightening only the pill spacing. */
@container(max-height:115px){
 #online .perk-card .perk-benefits{gap:2px}
 #online .perk-card .perk-benefits li{min-height:20px;padding-top:0;padding-bottom:0;font-size:12px}
}
/* These existing fallback headers have a taller line box. */
@container(max-height:123px){
 html:is([lang="ko"],[lang="zh-Hans"],[lang="zh-Hant"]) #online .perk-card .perk-benefits{gap:2px}
 html:is([lang="ko"],[lang="zh-Hans"],[lang="zh-Hant"]) #online .perk-card .perk-benefits li{min-height:20px;padding-top:0;padding-bottom:0;font-size:12px}
}
.perk-card-action .perk-lock,#online .perk-card-action .perk-claim{width:100%;min-width:0;padding-left:6px;padding-right:6px}
.perk-card-action .perk-lock{gap:5px;font-size:16px}
.perk-card .perk-claimed b{color:#d8ffcf;-webkit-text-stroke:1px var(--ink-navy);paint-order:stroke fill}
.perk-card .perk-claimed small{color:#eef}

/* AC796 (build 182 feedback, supersedes the AC787 title-row strip): the Mining Card is a full paid card and the Cards
   tab scrolls only its card list (.perks-cards); the tabs, the title with (?) and the bottom bar stay fixed. Every paid
   card keeps the height the two paid cards had on the fixed screen (half of the list box after Daily Benefits), so
   the first screen looks as before and the Mining Card is one more card of the same size. */
.perks-cards{display:flex;flex-direction:column;gap:8px;flex:1 1 auto;min-height:0;margin:0 -4px;padding:0 4px 4px;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;scrollbar-width:none;container-type:size;container-name:perks-cards}
.perks-cards::-webkit-scrollbar{display:none}
.perks-cards>.perk-daily{flex:none}
.perks-cards>.perk-card{flex:none;height:max(168px,calc((100cqh - 78px - 20px) / 2))}
.perk-card.is-mining{border-color:#3a2414;background:linear-gradient(135deg,#c8823c,#8a5426);box-shadow:inset 0 2px #ffffff40,0 3px #2a1a0e}
#online .perk-card.is-mining h2{-webkit-text-stroke-color:#2a1a0e}
.perk-card.is-mining .perk-benefits li{background:#3a20104d}
.perk-card.is-mining .perk-card-art img{max-height:84px}
.perk-auto-mark{font-size:8px;letter-spacing:.02em}
/* The AUTO mark is wider than the 20px icon slot: its slot grows so the label never runs under it. */
.perk-benefit-icon:has(.perk-auto-mark){width:auto;min-width:20px}
/* The same card opened over Buried Treasures (AC797): a fixed card height inside the standard sheet. */
/* AC803 (build 184, owner: "Czemu karta jak węższa niż button"): the offer card spans the dialog like its Close button. */
.perks-offer-sheet{display:flex;flex-direction:column;width:100%;margin:0 auto}
.perks-offer-sheet>.perk-card{flex:none;height:220px;text-align:left}
#modal .perks-offer-sheet .perk-card h2{margin:0;color:#fff;font:23px/1.05 Lucky;-webkit-text-stroke:1.5px #2a1a0e;paint-order:stroke fill;white-space:nowrap}
#modal .perks-offer-sheet .perk-card-action>*{width:100%}
#modal .perks-offer-sheet .store-buy{font-size:var(--tier-full-fs);min-height:var(--tier-full-h);margin:0;padding:6px 8px;white-space:nowrap;translate:0 -4px}

/* Growth funds */
.fund-banner{position:relative;display:grid;grid-template-columns:minmax(0,1fr) auto;grid-template-areas:'title title' 'copy side';align-items:end;gap:8px 10px;flex:none;min-height:104px;padding:8px 10px;border:3px solid #1e2c4a;border-radius:16px;overflow:hidden;color:#fff;isolation:isolate}
.fund-banner-art{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;z-index:-2}
.fund-banner-shade{position:absolute;inset:0;background:linear-gradient(90deg,#141a33e6 0,#141a33b3 55%,#141a3355);z-index:-1}
.fund-banner-copy{grid-area:copy;min-width:0;align-self:center}
.fund-banner>h2{grid-area:title;min-width:0;padding-right:44px;min-height:44px}
.fund-banner>.help-button{position:absolute;right:6px;top:6px}
.fund-banner:has(>.perk-status) .fund-banner-side{padding-bottom:24px}
.fund-banner>.perk-status{position:absolute;right:0;bottom:0;border-radius:10px 0 0 0}
#online .fund-banner h2{display:flex;align-items:center;gap:6px;margin:0;color:#fff;font:23px/1.1 Lucky;-webkit-text-stroke:1.5px var(--ink-navy);paint-order:stroke fill}
.fund-banner h2 img{width:30px;height:30px;object-fit:contain}
#online .fund-banner p{margin:0;color:#ffd98a;font:800 12px/1.3 system-ui}
.fund-progress{display:block;margin-top:3px;color:#e8e4ff;font:800 12px/1.3 system-ui}
.fund-banner-side{grid-area:side;display:flex;flex-direction:column;align-items:flex-end;gap:5px}
.fund-total{display:flex;flex-direction:column;align-items:flex-end;padding:3px 8px;border-radius:9px;background:#0c1022cc}
.fund-total small{color:#cfc8e8;font:800 10px/1.2 system-ui}
.fund-banner .perk-lock{min-height:36px;padding:3px 10px;font-size:16px}
.fund-board{display:flex;flex-direction:column;flex:1 1 auto;min-height:0;border:3px solid #2b2238;border-radius:14px;overflow:hidden;background:linear-gradient(90deg,#5a3fa8 0 50%,#f2b84a 50% 100%)}
.fund-head{display:grid;grid-template-columns:1fr 1fr;flex:none}
.fund-head b{display:grid;place-items:center;min-height:30px;font:19px/1 Lucky;-webkit-text-stroke:1.5px #2b2238;paint-order:stroke fill}
.fund-head .is-free{color:#ffe36b;background:#4a3291}
.fund-head .is-fund{color:var(--cream-300);background:#d9952c}
.fund-rows{display:grid;grid-template-rows:repeat(var(--fund-rows,5),minmax(0,1fr));flex:1 1 auto;min-height:0;margin:0;padding:0;list-style:none}
.fund-row{position:relative;display:grid;grid-template-columns:1fr 92px 1fr;align-items:center;justify-items:center;min-height:0;border-top:2px solid #2b223855}
.fund-row:before{content:"";position:absolute;left:50%;top:0;bottom:0;width:8px;margin-left:-4px;background:#e8a53a;border-left:2px solid #2b2238;border-right:2px solid #2b2238}
.fund-row.is-reached:before{background:#ffd24a}
.fund-mark{position:relative;display:flex;flex-direction:column;align-items:center;gap:1px;z-index:1}
.fund-mark-icon{width:30px;height:30px;object-fit:contain;filter:drop-shadow(0 1px 1px #000a)}
.fund-mark b{padding:1px 6px;border-radius:7px;background:#2b2238;color:#fff;font:800 11px/1.3 system-ui;white-space:nowrap}
.fund-row:not(.is-reached) .fund-mark b{background:#5b5468}
.fund-tile{position:relative;display:grid;place-items:center;width:54px;height:54px;margin:0;padding:0;border:2px solid #4a3016;border-radius:11px;background:linear-gradient(#e7b56b,#c4823c);box-shadow:inset 0 2px #fff5,0 2px #2b2238}
.fund-tile img{width:42px;height:42px;object-fit:contain}
.fund-tile-count{position:absolute;right:2px;bottom:0;color:#fff;font:13px/1 Lucky;-webkit-text-stroke:2px #2b2238;paint-order:stroke fill}
button.fund-tile{cursor:pointer;touch-action:manipulation;min-width:54px}
button.fund-tile:before{display:none}
.fund-tile.is-claimable{border-color:#fff3a8;background:linear-gradient(#ffd77d,#f0a23a);box-shadow:0 0 0 2px #2b2238,0 0 14px 4px #fff0a0,0 2px #2b2238;animation:fund-ready 1.6s ease-in-out infinite}
.fund-tile.is-claimable:active{scale:.94}
.fund-tile.is-claimed{background:linear-gradient(#b9a68f,#8f7a63)}
.fund-tile.is-claimed img{filter:saturate(.35) brightness(.9)}
.fund-tile-check{position:absolute;inset:0;display:grid;place-items:center;color:#9cff6b;font:900 30px/1 system-ui;-webkit-text-stroke:2px #1f3d17;paint-order:stroke fill;font-style:normal}
.fund-tile.is-locked{border-color:#3b3550;background:linear-gradient(#aaa4bd,#7f7896)}
.fund-tile.is-locked img{filter:saturate(.6) brightness(.95)}
.fund-tile.is-fund-locked{background:linear-gradient(#d8c49d,#b39669)}
.fund-tile-lock{--lock-w:12px;--lock-h:10px;position:absolute;right:-6px;top:-6px;width:24px;height:24px;box-sizing:border-box;border:2px solid var(--row-face);border-radius:50%;background:radial-gradient(circle at 50% 35%,#4d4664,#2b2238);box-shadow:0 2px #1b1526}
.fund-tile-lock:before{bottom:calc(5px + var(--lock-h) - 3px);border-width:2px;border-color:#c9c4da}
.fund-tile-lock:after{bottom:5px}
@keyframes fund-ready{0%,100%{transform:none}50%{transform:translateY(-2px)}}
@media(prefers-reduced-motion:reduce){.fund-tile.is-claimable{animation:none}}
/* Bottom bar: Back + Claim all */
#tabs.has-perks-claim{display:grid!important;grid-template-columns:84px minmax(0,1fr);align-items:center}
/* AC770: Claim all hugs its label; AC844 (build 194): at the bar's right edge, opposite Back (story-ui.css → .bar-claim-all). */
#tabs.has-perks-claim .perks-claim-all{justify-self:end;width:auto;min-width:min(var(--claim-hug-min),100%);max-width:100%;min-height:var(--tier-full-h);margin:0;padding:6px 24px;font-size:var(--tier-full-fs);white-space:nowrap}
#tabs .perks-claim-all:not(:disabled){--small-top:var(--btn-claim-top);--small-bottom:var(--btn-claim-bottom);--small-edge:var(--btn-claim-edge);--small-lip:var(--btn-claim-lip);--small-shine:var(--btn-claim-shine)}
/* AC480 (build 109): with nothing to claim, a fund tab's bottom-right corner leads to its
   source (Fight → Tower, Adventure → Story). The shared small face, honey like Claim all,
   painted 48px tall like the Back arrow beside it (the bar's plates fill their buttons),
   with the source's icon before a one-word label at the full 24px tier. */
#tabs.has-perks-go{display:flex!important;align-items:center;justify-content:space-between}
#tabs .perks-go{flex:none;width:auto;min-width:112px;height:48px;min-height:48px;margin:0 0 0 auto;padding:4px 16px 4px 12px;font-size:var(--tier-full-fs);white-space:nowrap}
#tabs .perks-go:not(:disabled){--small-top:#ffd96b;--small-bottom:#f0a72f;--small-edge:#4a2a0c;--small-lip:#b8681c;--small-shine:var(--cream-350)}
#tabs .perks-go>.button-label{display:flex;align-items:center;gap:7px}
#tabs .perks-go .perks-go-icon{flex:none;width:30px;height:30px;object-fit:contain;filter:drop-shadow(0 2px 0 #4a2a0c66);transform:translateY(.12em)}

/* Help sheet */
.perks-help p{margin:0 0 8px}

/* Compact heights: tighter cards so the whole tab fits without scrolling. */
@media(max-height:730px){
 .perks-panel{gap:6px;padding:8px}
 .perks-body{gap:6px}
 .perks-head{min-height:34px}
 #online .perks-head h1{font-size:24px}
 .perk-daily{min-height:66px;padding:5px 8px;grid-template-columns:52px minmax(0,1fr) auto}
 .perk-gem-tile{width:50px;height:50px}.perk-gem-tile img{width:32px;height:32px}
 .perk-card{padding:20px 8px 6px;gap:3px}
 .perk-card.is-monthly{padding-top:19px;padding-bottom:4px;gap:1px}
 .perk-card.is-monthly .perk-benefits{gap:2px}
 .perk-card.is-monthly .perk-benefits li:nth-child(2){padding-top:1px;padding-bottom:1px}
 .perk-benefits{gap:3px}.perk-benefits li{min-height:21px;font-size:12px}
 .perk-card-art img{max-height:52px}
 .perk-card-main{grid-template-columns:minmax(0,1fr) 134px}
 html[lang="pl"] .perk-card.is-monthly .perk-card-main{grid-template-columns:minmax(0,1fr) 116px}
 .fund-banner{min-height:84px;padding-top:5px;padding-bottom:5px;gap:2px 6px}
 .fund-head b{min-height:24px;font-size:17px}
 /* The lead line repeats the (?) help; Compact keeps the progress line only. */
 #online .fund-banner p{display:none}
 .perks-head{margin-top:2px}
 /* Integration fix (build 50): the rows share what the banner leaves, and a CJK
    lock chip wraps the banner taller (zh-Hans rows 54px), so 46px tiles keep the
    4px face gap between rows. */
 .fund-tile,button.fund-tile{width:46px;min-width:46px;height:46px}
 .fund-tile img{width:41px;height:41px}
 #online .fund-banner h2{font-size:20px}
}
/* AC197: the Coming soon chip and fund tiles use the painted padlock art, not a CSS drawing. */
.perk-lock i,.fund-tile-lock{background:url('/art/ui-lock-v1/padlock.png') center/contain no-repeat}
.perk-lock i{width:16px;height:18px;margin-top:0}
.perk-lock i:before,.perk-lock i:after,.fund-tile-lock:before,.fund-tile-lock:after{content:none}
.fund-tile-lock{right:-5px;top:-7px;width:22px;height:24px;border:0;border-radius:0;box-shadow:none}
