/* ---- chest opening ---- */
.chest-overlay { position: fixed; inset: 0; z-index: 85; display: flex; align-items: center; justify-content: center; overflow: hidden; background: radial-gradient(circle at 50% 45%, rgba(40,25,80,.94), rgba(0,0,0,.97)); }
.chest-stage { position: relative; width: min(92vw, 420px); height: min(90vh, 600px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.chest-text { min-height: 24px; font-weight: 900; font-size: 1.05rem; color: #fff; text-align: center; text-shadow: 0 2px 8px #000; z-index: 3; }
.chest-rays { position: absolute; left: 50%; top: 46%; width: 560px; height: 560px; margin: -280px 0 0 -280px; border-radius: 50%; opacity: 0; pointer-events: none; background: repeating-conic-gradient(from 0deg, var(--glow, #fbbf24) 0 7deg, transparent 7deg 20deg); -webkit-mask: radial-gradient(circle, #000 12%, transparent 68%); mask: radial-gradient(circle, #000 12%, transparent 68%); animation: raySpin 9s linear infinite; transition: opacity .5s; }
.chest-rays.on { opacity: .6; }
@keyframes raySpin { to { transform: rotate(360deg); } }
#chestSvg { z-index: 2; filter: drop-shadow(0 12px 18px rgba(0,0,0,.6)); overflow: visible; }
#chestSvg.drop { animation: chestDrop .85s cubic-bezier(.3,1.5,.5,1); }
#chestSvg.shake { animation: chestShake .8s ease-in-out; }
#chestSvg.shake2 { animation: chestShake2 1.2s ease-in-out; }
@keyframes chestDrop { 0% { transform: translateY(-380px) scale(.8); } 100% { transform: none; } }
@keyframes chestShake { 0%,100% { transform: rotate(0); } 12% { transform: rotate(-4deg) translateX(-4px); } 28% { transform: rotate(4deg) translateX(4px); } 44% { transform: rotate(-5deg) translateX(-5px); } 60% { transform: rotate(5deg) translateX(5px); } 78% { transform: rotate(-3deg); } }
@keyframes chestShake2 { 0%,100% { transform: rotate(0) scale(1); } 10% { transform: rotate(-6deg) scale(1.03); } 22% { transform: rotate(6deg) scale(1.05); } 34% { transform: rotate(-7deg) scale(1.07); } 46% { transform: rotate(7deg) scale(1.08); } 60% { transform: rotate(-8deg) scale(1.1); } 74% { transform: rotate(8deg) scale(1.1); } 88% { transform: rotate(-4deg) scale(1.06); } }
#chLid { transform-origin: 100px 100px; transition: transform .6s cubic-bezier(.2,1.7,.4,1); }
#chLid.open { transform: translateY(-40px) rotate(-16deg); }
#chGlow { transition: opacity .4s; }
.chest-key { position: absolute; left: 50%; top: 50%; font-size: 52px; z-index: 4; transform: translate(-50%, 190px); filter: drop-shadow(0 4px 8px #000); }
.chest-key.fly { animation: keyFly 1s ease-in-out forwards; }
@keyframes keyFly { 0% { transform: translate(-50%, 190px) rotate(-30deg) scale(1.3); opacity: 0; } 25% { opacity: 1; } 70% { transform: translate(-50%, -30px) rotate(0deg) scale(1); } 100% { transform: translate(-50%, -30px) rotate(90deg) scale(.8); opacity: 0; } }
.chest-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 6; }
.chest-flash.go { animation: flashGo .7s ease-out; }
@keyframes flashGo { 0% { opacity: .9; } 100% { opacity: 0; } }
.chest-burst { position: absolute; left: 50%; top: 46%; z-index: 5; pointer-events: none; font-size: 18px; animation: chestBurstFly 1.2s ease-out forwards; color: var(--glow, #fbbf24); }
@keyframes chestBurstFly { 0% { transform: translate(-50%,-50%) scale(.3); opacity: 1; } 100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.6) rotate(300deg); opacity: 0; } }
.reward-card { position: absolute; left: 50%; top: 46%; width: 220px; height: 270px; margin: -135px 0 0 -110px; z-index: 7; perspective: 900px; animation: rewardPop .7s cubic-bezier(.2,1.5,.4,1); }
@keyframes rewardPop { 0% { transform: scale(0) translateY(60px); opacity: 0; } 100% { transform: none; opacity: 1; } }
.reward-inner { position: relative; width: 100%; height: 100%; transition: transform .9s cubic-bezier(.3,1.2,.4,1); transform-style: preserve-3d; }
.reward-inner.flipped { transform: rotateY(180deg); }
.reward-face { position: absolute; inset: 0; border-radius: 20px; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 14px; }
.reward-back { background: repeating-linear-gradient(45deg, #1e1b4b 0 10px, #312e81 10px 20px); border: 3px solid var(--glow, #fbbf24); font-size: 4rem; font-weight: 900; color: var(--glow, #fbbf24); }
.reward-front { transform: rotateY(180deg); background: linear-gradient(160deg, #1f2937, #0b1020); border: 3px solid var(--glow, #fbbf24); box-shadow: 0 0 46px var(--glow, #fbbf24); }
.chest-actions { position: absolute; bottom: 18px; z-index: 8; display: flex; gap: 10px; }
html[data-gfx="low"] .chest-rays { display: none; }
.chest-overlay.hidden { display: none; }   /* make sure the closed chest screen can never cover the page */
