/* Gemstone stat reroll (AC83, gem-reroll-v1; reroll-ui.js). Fixed-fit dialogs: nothing
 * scrolls at 375x667 (docs/MOBILE_UI.md). Motion: transform/opacity only; reduced
 * motion shows the landed result with no reel, lamps, burst or sparkles. */
.reroll-scroll-art{width:28px;height:28px;object-fit:contain;vertical-align:middle;filter:drop-shadow(0 1px 1px #3a2a1a40)}
/* AC245: the scroll cost sits inside the existing full-width price action. */
.gem-reroll-row{width:100%;display:flex;justify-content:center;margin:8px 0 2px}
#modal .gem-reroll-row .gem-reroll-open{width:100%;margin:0;--price-face-pad:9px}
/* Reroll sheet */
.reroll-sheet{display:grid;gap:10px;text-align:center}
.reroll-heading{position:relative;display:flex;justify-content:center;align-items:center;min-height:44px}
.reroll-heading h1{margin:0}
.reroll-heading .help-button{position:absolute;right:0;top:0}
/* AC479 (build 109, owner: "To zrób ładniej"): the stone stands on a soft halo of its rarity
   colour with the rarity plate across its lower edge; the current stat is a chip; the quoted
   results are equal chips with their stat icons, the current one tagged; the scroll wallet is
   one compact line (red when short); the cost is the price inside Reroll. Rules stay in (?). */
.reroll-stone{position:relative;isolation:isolate;display:grid;justify-items:center;padding-top:2px}
.reroll-halo{position:absolute;left:50%;top:46px;z-index:-1;width:184px;height:118px;translate:-50% -50%;border-radius:50%;background:radial-gradient(closest-side,color-mix(in srgb,var(--gem-color) 48%,transparent),color-mix(in srgb,var(--gem-color) 20%,transparent) 62%,transparent);pointer-events:none}
.reroll-stone .gemstone-detail-art{width:88px;height:88px;margin:0}
.reroll-rarity{position:relative;z-index:1;margin-top:-11px;padding:2px 12px 3px;border:2px solid var(--vs-ink);border-radius:9px;background:linear-gradient(color-mix(in srgb,var(--gem-color) 78%,#fff),color-mix(in srgb,var(--gem-accent) 70%,#2b1d3c));box-shadow:0 2px 0 var(--vs-ink);color:#fff;font:15px/1.15 Lucky,system-ui,sans-serif;-webkit-text-stroke:3px var(--vs-ink-text);paint-order:stroke fill;text-shadow:none;white-space:nowrap}
.reroll-sheet [data-stat=hp]{--stat-ink:#b8352f}.reroll-sheet [data-stat=attack]{--stat-ink:#97520f}.reroll-sheet [data-stat=defense]{--stat-ink:#2c67a3}
.reroll-current{justify-self:center;display:inline-flex;align-items:center;gap:6px;margin:0;padding:3px 14px 3px 8px;border:2px solid var(--vs-ink);border-radius:999px;background:var(--cream-200);box-shadow:0 2px 0 var(--vs-ink)}
.reroll-current .reroll-stat-icon{width:28px;height:28px;object-fit:contain}
.reroll-current b{font:24px/1.1 Lucky,system-ui,sans-serif;color:var(--stat-ink)}
.reroll-where{margin-top:-4px;color:#7a6142}
.reroll-outcomes{display:grid;gap:12px;margin:2px 0 0}
.reroll-outcomes h2{margin:0;font:800 12px/1.2 system-ui,sans-serif;letter-spacing:.06em;text-transform:uppercase;color:#7a6142}
.reroll-outcomes ul{display:grid;grid-template-columns:repeat(var(--reroll-options,3),minmax(0,1fr));gap:8px;margin:0;padding:0;list-style:none}
.reroll-option{position:relative;display:grid;justify-items:center;align-content:center;gap:3px;min-height:66px;padding:9px 4px 7px;border:2px solid var(--vs-ink);border-radius:var(--vs-radius);background:var(--row-face);box-shadow:0 3px 0 var(--vs-ink)}
.reroll-option .reroll-stat-icon{width:28px;height:28px;object-fit:contain}
.reroll-option b{font:17px/1.1 Lucky,system-ui,sans-serif;color:var(--stat-ink);white-space:nowrap}
.reroll-option.is-current{background:var(--gold-100)}
.reroll-option-tag{position:absolute;top:-10px;left:50%;transform:translateX(-50%);padding:1px 8px 2px;border:1.5px solid var(--vs-ink);border-radius:8px;background:var(--cream-50);color:var(--text-on-cream);font:800 10px/1.2 system-ui,sans-serif;font-style:normal;white-space:nowrap}
.reroll-wallet{justify-self:center;display:inline-flex;align-items:center;gap:6px;margin:0;padding:2px 12px 2px 6px;border-radius:999px;background:#5b432614;font:800 13px/1.2 system-ui,sans-serif;color:#5b4326}
.reroll-wallet .reroll-scroll-art{width:22px;height:22px}
.reroll-wallet.is-short{background:#9b43391a;color:#9b4339}
/* The cost rides inside Reroll, inline at the footer's 56px face like Arena Refresh, in the
   label's own lettering; a short wallet leaves the shared solid disabled face. */
#modal .reroll-confirm{display:flex;flex-direction:row;align-items:center;justify-content:center;gap:8px;white-space:nowrap}
#modal .reroll-confirm>.button-label+.gemstone-price{margin-top:0}
#modal .reroll-confirm .gemstone-price{font:inherit;color:inherit;-webkit-text-stroke:inherit;text-shadow:inherit}
#modal .reroll-confirm .reroll-scroll-art{width:26px;height:26px}
.reroll-cost{display:flex;align-items:center;justify-content:center;gap:6px;margin:0;color:#5b4326;font-weight:700}
.reroll-cost small{color:#7a6142;font-weight:600}
.reroll-reason{display:block}
/* Result: a little slot machine. Lamps chase, the value window spins, then lands. */
.reroll-result{display:grid;gap:10px;text-align:center}
.reroll-result h1{margin:0}
.reroll-machine{position:relative;display:grid;justify-items:center;gap:10px;padding:14px 12px 16px;border-radius:22px;background:linear-gradient(#5a3f8c,#3a2763);border:3px solid #2a1a49;box-shadow:inset 0 2px #9f86d9,0 4px 0 #24163f;overflow:hidden;isolation:isolate}
.reroll-machine .reroll-gem{width:76px;height:76px;margin:0}
.reroll-lamp{position:absolute;top:8px;width:10px;height:10px;border-radius:50%;background:var(--honey-300);box-shadow:0 0 8px 2px #ffcf4acc;opacity:.35}
.reroll-lamp:nth-child(1){left:14px}.reroll-lamp:nth-child(2){left:50%;translate:-50% 0}.reroll-lamp:nth-child(3){right:14px}
.reroll-window{position:relative;width:min(240px,100%);height:58px;border-radius:14px;background:linear-gradient(var(--cream-50),var(--row-face));border:3px solid #24163f;box-shadow:inset 0 6px 8px #0002,inset 0 -6px 8px #0002;overflow:hidden;display:grid;place-items:center}
.reroll-value{display:block;font:30px/1 Lucky;color:#5b4326;white-space:nowrap}
.reroll-value[data-stat="hp"]{color:#c4413d}.reroll-value[data-stat="attack"]{color:#b86a17}.reroll-value[data-stat="defense"]{color:#2f6fae}
.reroll-value.is-tick{animation:reroll-tick 90ms linear both}
@keyframes reroll-tick{from{translate:0 -70%;opacity:.4;filter:blur(1.5px)}to{translate:0 0;opacity:1;filter:none}}
.reroll-result.is-spinning:not(.is-landed) .reroll-lamp{animation:reroll-lamp .36s steps(1) infinite}
.reroll-result.is-spinning:not(.is-landed) .reroll-lamp:nth-child(2){animation-delay:.12s}
.reroll-result.is-spinning:not(.is-landed) .reroll-lamp:nth-child(3){animation-delay:.24s}
@keyframes reroll-lamp{0%{opacity:1}34%,100%{opacity:.35}}
.reroll-result.is-spinning:not(.is-landed) .reroll-gem{animation:reroll-wobble .5s ease-in-out infinite}
@keyframes reroll-wobble{50%{rotate:-6deg;scale:1.04}}
.reroll-result.is-landed .reroll-lamp{opacity:1}
.reroll-result.is-landed:not(.is-reduced) .reroll-value{animation:reroll-land .42s cubic-bezier(.2,1.6,.4,1) both}
@keyframes reroll-land{0%{scale:.6}60%{scale:1.18}100%{scale:1}}
.reroll-burst{position:absolute;left:50%;top:50%;width:240px;height:240px;translate:-50% -50%;border-radius:50%;background:radial-gradient(circle,var(--gold-50) 0%,#ffd86a99 30%,transparent 65%);opacity:0;pointer-events:none;z-index:-1}
.reroll-result.is-landed:not(.is-reduced) .reroll-burst{animation:reroll-burst .6s ease-out both}
@keyframes reroll-burst{0%{opacity:0;scale:.3}30%{opacity:1}100%{opacity:0;scale:1.3}}
.reroll-spark{position:absolute;left:50%;top:62%;width:8px;height:8px;border-radius:50%;background:#fff6b0;box-shadow:0 0 6px 2px #ffd86a;opacity:0;pointer-events:none}
.reroll-spark:nth-of-type(1){--x:-110px;--y:-56px}.reroll-spark:nth-of-type(2){--x:110px;--y:-50px}.reroll-spark:nth-of-type(3){--x:-96px;--y:20px}
.reroll-spark:nth-of-type(4){--x:100px;--y:24px}.reroll-spark:nth-of-type(5){--x:-40px;--y:-92px}.reroll-spark:nth-of-type(6){--x:46px;--y:-90px}
.reroll-result.is-landed:not(.is-reduced) .reroll-spark{animation:reroll-spark .7s ease-out both}
@keyframes reroll-spark{0%{opacity:0;translate:-50% -50%}25%{opacity:1}100%{opacity:0;translate:calc(-50% + var(--x)) calc(-50% + var(--y))}}
.reroll-final{min-height:1.3em;margin:0;font-weight:700;color:#5b4326}
.reroll-result.is-reduced .reroll-value{animation:reroll-fade .15s linear both}
@keyframes reroll-fade{from{opacity:0}to{opacity:1}}
.exchange-card-art .reroll-scroll-art,.exchange-detail-art .reroll-scroll-art{width:72px;height:72px}
/* AC544 (build 125 feedback, "Ten zwój za duży"): the scroll art fills its PNG edge to edge, so in a tile it is drawn
   at 72% of the face (about 28px painted in a 56px Backpack tile), the same visual size as the other items. */
.backpack-slot .reroll-scroll-art{width:72%;height:72%}
.login-reward .reroll-scroll-art{width:64px;height:64px}
@media (max-height:700px){.reroll-sheet{gap:8px}.reroll-stone .gemstone-detail-art{width:72px;height:72px}.reroll-halo{top:38px;width:160px;height:100px}.reroll-option{min-height:60px;padding:8px 4px 6px}.reroll-machine{padding:10px 10px 12px;gap:8px}.reroll-machine .reroll-gem{width:60px;height:60px}.reroll-window{height:50px}.reroll-value{font-size:26px}}
@media (prefers-reduced-motion:reduce){.reroll-result *{animation:none!important}}

/* AC176: grade badges reuse the canonical design palette, independently of rarity. */
.gemstone-card,.gemstone-detail-art,.gemstone-tile-mini,.gemstone-merge-art>div{position:relative}
.gemstone-grade{position:absolute;left:8px;bottom:25px;z-index:2;display:grid;place-items:center;min-width:16px;height:16px;padding:0 2px;box-sizing:border-box;border:1px solid #3f3339;border-radius:4px;background:var(--grade-color);color:#231c29;font:11px/1 Lucky;box-shadow:0 1px #3f3339;pointer-events:none}
.gemstone-detail-art .gemstone-grade,.gemstone-merge-art .gemstone-grade,.gemstone-tile-mini .gemstone-grade{left:5px;bottom:5px}
.socket-stone .gemstone-grade,.eq-gem-marker .gemstone-grade{left:0;bottom:0;min-width:12px;height:12px;padding:0 1px;font-size:9px;border-width:1px;border-radius:3px;box-shadow:none}
.reroll-grade-choice{display:flex;justify-content:center}
#modal .reroll-grade-choice button{width:100%;margin:0}
#modal .gemstone-grade-odds{margin-top:8px}
#modal .gemstone-grade-odds h2{font-size:20px;margin:0 0 6px}
@media(max-height:760px){#modal .gemstone-grade-odds{padding-block:6px}#modal .gemstone-grade-odds p{min-height:16px}}
.reroll-result.is-grade .reroll-value{font-size:25px}

/* AC661: one label-plus-price row; copy gives way before the quoted cost. */
#modal .gem-reroll-row .gem-reroll-open{display:flex;flex-direction:row;align-items:center;justify-content:center;gap:12px;min-height:56px;padding-inline:12px;--price-face-pad:9px;--price-face-cjk:0px;--price-face-grow:0px;font-size:clamp(19px,5.6vw,24px)}
#modal .gem-reroll-open>.button-label{min-width:0;white-space:nowrap;padding-block:calc((1lh - 1cap) / 2)}
#modal .gem-reroll-open>.button-label+.gemstone-price{flex:none;display:flex;align-items:center;gap:6px;margin:0;padding:3px 8px;border-radius:9px;background:#00000018;font:800 14px/1 system-ui;white-space:nowrap}
#modal .gem-reroll-open .reroll-scroll-art{width:22px;height:22px}

/* AC662: existing compact secondary plate (32px face / 44px target), one action
   below the gem it changes. AC631's inherited lip and face-shift centre its ink. */
#modal .gemstone-comparison .gemstone-tile-action{width:112px;max-width:100%;height:44px;min-height:44px;margin:5px 0 0;white-space:nowrap}
.gemstone-tile-action-space{height:44px;flex:none;margin-top:5px}
