/* v1.41 Okna zdobyczy: jeden wygląd i jedna kolejność animacji dla wszystkiego, co gracz otwiera albo zdobywa
   (skrzynka, przedmiot z Fabryki, paczka kart, nowa ranga). Oś czasu:
   tło (0 s) → bohater wjeżdża (0–0,45 s) → błysk, promienie i iskry (.open) → napis → panel → łupy po kolei → przyciski.
   Zamykanie: .out (krótkie wygaszenie zamiast znikania w miejscu). */
:root { --rv-spring: cubic-bezier(.18, 1.35, .4, 1); --rv-ease: cubic-bezier(.22, .8, .3, 1); }

/* tło */
.cap-ovl, .kopen-ov {
  background: radial-gradient(circle at 50% 36%, color-mix(in srgb, var(--cc, #c6ff00) 22%, rgba(6, 8, 12, .9)), rgba(6, 8, 12, .97) 64%);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.cap-ovl { transition: opacity .3s var(--rv-ease); }
.kopen-ov { --cc: #c6ff00; animation: rvFade .3s var(--rv-ease) both; }
.cap-ovl.out { opacity: 0; transition: opacity .22s ease; pointer-events: none; }
.cap-ovl.out > * { transform: scale(.96); transition: transform .22s ease; }

/* scena bohatera: poświata pod spodem, błysk przy odkryciu, iskry */
.co-stage::before { content: ''; position: absolute; inset: 8%; z-index: 0; border-radius: 50%; opacity: 0; pointer-events: none;
  background: radial-gradient(circle, color-mix(in srgb, var(--cc) 50%, transparent), transparent 68%); }
.cap-ovl.open .co-stage::before { animation: rvFade .4s ease forwards, rvPulse 2.6s .4s ease-in-out infinite; }
.co-stage::after { content: ''; position: absolute; inset: 6%; z-index: 4; border-radius: 50%; opacity: 0; pointer-events: none; mix-blend-mode: screen;
  background: radial-gradient(circle, #fff 0, color-mix(in srgb, var(--cc) 65%, #fff) 22%, transparent 64%); }
.cap-ovl.open .co-stage::after { animation: rvFlash .6s ease-out; }
.rv-sparks { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.rv-sparks i { position: absolute; left: 50%; top: 50%; width: var(--s, 6px); height: var(--s, 6px); margin: calc(var(--s, 6px) / -2); border-radius: 50%; opacity: 0;
  background: color-mix(in srgb, var(--cc) 55%, #fff); box-shadow: 0 0 10px var(--cc), 0 0 2px #fff; }
.cap-ovl.open .rv-sparks i { animation: rvSpark .95s var(--t, 0s) cubic-bezier(.12, .7, .3, 1) forwards; }

/* bohater: wjazd sprężyną, przy odkryciu krótkie „bum” */
.co-chest { animation: coIn .5s var(--rv-spring) both; }
.co-chest.shake { animation: coIn .5s var(--rv-spring) both, rvShake .55s .5s ease-in-out infinite; }
.cap-ovl.open .co-chest { animation: rvPop .55s var(--rv-spring) both; }
.cap-ovl.open .co-chest.fab-it, .cap-ovl.open .co-chest.rk-hero { animation: coIn .5s var(--rv-spring) both, rvPop .55s .35s var(--rv-spring); }

/* napis: mały nadtytuł w kolorze zdobyczy i nazwa */
.co-stage { margin-bottom: 30px; }
.co-name { bottom: -34px; display: flex; flex-direction: column; align-items: center; line-height: 1; text-align: center; opacity: 0; }
.cap-ovl.in .co-name { animation: rvRise .45s .2s var(--rv-ease) forwards; }
.rv-kick { display: block; margin-bottom: 6px; font-family: Rubik, system-ui, sans-serif; font-size: 12px; font-weight: 800; letter-spacing: .32em; text-transform: uppercase;
  color: var(--cc); text-shadow: 0 0 14px color-mix(in srgb, var(--cc) 60%, transparent); }

/* panel pod bohaterem */
.co-loot { opacity: 0; }
.cap-ovl.open .co-loot { animation: rvRise .5s .3s var(--rv-ease) forwards; }
.co-loot h3 { display: flex; flex-direction: column; align-items: center; }
.co-loot .btn { opacity: 1; animation: none; }

/* łupy ze skrzynki wpadają po kolei */
.co-loot .cap-loot > span { opacity: 0; animation: rvTile .5s calc(.5s + var(--i, 0) * .09s) var(--rv-spring) forwards; }
.co-loot .cap-loot > span .ico { filter: drop-shadow(0 4px 10px color-mix(in srgb, var(--cc) 40%, transparent)); }
.co-loot .row, .fab-acts { opacity: 0; animation: rvRise .4s calc(.65s + var(--n, 0) * .09s) var(--rv-ease) forwards; }
.cap-ovl:not(.open) .co-loot .row, .cap-ovl:not(.open) .fab-acts { animation: none; }

/* przedmiot z Fabryki i ranga: wiersze panelu po kolei, przyciski na środku */
.cap-ovl .fab-acts { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.fab-loot > *, .rk-loot > * { opacity: 0; }
.cap-ovl.open .fab-loot > *, .cap-ovl.open .rk-loot > * { animation: rvRise .4s calc(.45s + var(--i, 0) * .08s) var(--rv-ease) forwards; }
.fab-loot > :nth-child(2), .rk-loot > :nth-child(2) { --i: 1; } .fab-loot > :nth-child(3), .rk-loot > :nth-child(3) { --i: 2; }
.fab-loot > :nth-child(4), .rk-loot > :nth-child(4) { --i: 3; } .fab-loot > :nth-child(5), .rk-loot > :nth-child(5) { --i: 4; }
.fab-loot > :nth-child(6), .rk-loot > :nth-child(6) { --i: 5; } .fab-loot > :nth-child(7), .rk-loot > :nth-child(7) { --i: 6; }
.cap-ovl.open .fab-loot > .fab-acts, .cap-ovl.open .rk-loot > .fab-acts { animation-delay: .95s; }

/* nowa ranga w tym samym oknie */
.rk-hero { display: grid; place-items: center; width: 220px; height: 220px; }
.rk-hero .rkimg, .rk-hero img { width: 200px; height: 200px; object-fit: contain; }
.rk-loot { max-width: 480px; text-align: center; background: color-mix(in srgb, #0d0f14 88%, transparent); border: 1px solid var(--line);
  border-top: 3px solid var(--cc); border-radius: 14px; padding: 16px 20px; }
.rk-loot .co-txt { margin: 0 0 10px; } .rk-loot .rkup-rew { margin: 0 0 8px; }
.rk-loot .fab-acts { display: flex; justify-content: center; margin-top: 10px; }

/* paczka kart: ta sama scena, karty odwracają się po kolei, przyciski po ostatniej */
.kopen-in { position: relative; z-index: 1; }
.kopen-ov::before { content: ''; position: fixed; left: calc(50% - 490px); top: calc(42% - 490px); width: 980px; height: 980px; pointer-events: none; z-index: 0;
  background: repeating-conic-gradient(from 0deg, color-mix(in srgb, var(--cc) 11%, transparent) 0 7deg, transparent 7deg 22deg);
  -webkit-mask-image: radial-gradient(circle, #000 10%, transparent 60%); mask-image: radial-gradient(circle, #000 10%, transparent 60%);
  animation: rvFade .8s ease both, coSpin 40s linear infinite; }
.kopen-in h3 { display: flex; flex-direction: column; align-items: center; margin: 0 0 16px; font-family: var(--display); font-weight: 400; font-size: 34px; letter-spacing: 1px; color: #fff;
  animation: rvRise .45s .05s var(--rv-ease) both; }
.kopen-in h3::before { display: none; }
.kopen-in .kflipw { animation: rvTile .45s calc(var(--fd, .2s) - .2s) var(--rv-spring) both; }
.kopen-act, .kopen-in .kjok-drop { animation: rvRise .4s var(--ad, 1.2s) var(--rv-ease) both; }

@keyframes rvFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rvRise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes rvTile { 0% { opacity: 0; transform: translateY(20px) scale(.6); } 60% { opacity: 1; } 100% { opacity: 1; transform: none; } }
@keyframes rvPop { 0% { transform: scale(1); } 35% { transform: scale(1.16); } 100% { transform: scale(1); } }
@keyframes rvFlash { 0% { opacity: 0; transform: scale(.3); } 22% { opacity: .95; } 100% { opacity: 0; transform: scale(1.7); } }
@keyframes rvPulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.08); opacity: .75; } }
@keyframes rvSpark { 0% { opacity: 1; transform: rotate(var(--a)) translateX(0) scale(1); } 100% { opacity: 0; transform: rotate(var(--a)) translateX(var(--d)) scale(.3); } }
@keyframes rvShake { 0%, 100% { transform: rotate(0); } 15% { transform: rotate(-7deg) scale(1.04); } 35% { transform: rotate(6deg) scale(1.02); }
  55% { transform: rotate(-5deg) scale(1.06); } 75% { transform: rotate(3deg) scale(1.03); } }

@media (max-width: 560px) { .rk-hero { width: 160px; height: 160px; } .rk-hero .rkimg, .rk-hero img { width: 150px; height: 150px; } .co-loot .row .btn { flex: 1 1 100%; } }
@media (prefers-reduced-motion: reduce) {
  .co-stage::before, .co-stage::after, .rv-sparks i, .co-name, .co-loot, .co-loot .cap-loot > span, .co-loot .row, .fab-acts, .fab-loot > *, .rk-loot > *,
  .kopen-ov::before, .kopen-in h3, .kopen-in .kflipw, .kopen-act, .kopen-in .kjok-drop, .cap-ovl.open .co-chest { animation: none !important; opacity: 1; transform: none; }
  .rv-sparks, .co-stage::after { display: none; }
}
