.treasure-chest-anchor{position:absolute;left:84.8%;top:39%;width:320px;height:260px;transform:translate(-50%,-100%) scale(var(--chest-scale,1));transform-origin:50% 100%;perspective:900px;perspective-origin:50% 45%;z-index:1;}
.treasure-chest-anchor::before{content:'';position:absolute;left:12%;bottom:-7px;width:76%;height:24px;border-radius:50%;background:#173a5c70;filter:blur(7px);}
.chest-volume{position:absolute;left:50%;top:132px;transform-style:preserve-3d;transform:rotateX(-10deg) rotateY(162deg);transition:transform 2.2s cubic-bezier(.4,0,.2,1);}
.chest-volume.chest-turned{transform:rotateX(-10deg) rotateY(-18deg);}
.chest-face,.chest-lid-cap,.chest-lid-rail,.chest-roof-strip,.chest-lid-underside{position:absolute;backface-visibility:hidden;}
.chest-face{border:10px solid #e7ac38;box-shadow:inset 0 0 0 2px #fff0a0,inset 0 0 18px #27123866,0 0 0 1px #ac6c24;background:repeating-linear-gradient(90deg,transparent 0 29px,#39235045 30px,#a17ad133 32px),linear-gradient(120deg,#9671bf,#69509b 55%,#462d75);}
.chest-front,.chest-back{width:250px;height:122px;left:-125px;top:0;}
.chest-front{transform:translateZ(73px);}
.chest-back{transform:translateZ(-73px) rotateY(180deg);background:repeating-linear-gradient(90deg,#c38f3633 0 7px,transparent 7px 75px),linear-gradient(125deg,#725b9c,#432b6c);}
.chest-left,.chest-right{width:146px;height:122px;left:-73px;top:0;}
.chest-left{transform:translateX(-125px) rotateY(-90deg);}
.chest-right{transform:translateX(125px) rotateY(90deg);background:repeating-linear-gradient(90deg,transparent 0 26px,#3f24594d 27px 29px),linear-gradient(140deg,#78569e,#4a2c72);}
.chest-floor,.chest-inside{width:250px;height:146px;left:-125px;top:-73px;background:radial-gradient(ellipse,#d2a44b,#4f2c50 65%,#2b1946);}
.chest-floor{transform:translateY(122px) rotateX(90deg);}
.chest-inside{transform:translateY(5px) rotateX(-90deg);border-width:8px;}
.chest-rivet{position:absolute;width:9px;height:9px;border-radius:50%;transform:translate(-50%,-50%);background:radial-gradient(circle at 30% 25%,#fff7b3,#f4c552 45%,#b17024);box-shadow:0 1px 1px #8c562c;}
.chest-emblem{position:absolute;left:50%;top:52%;width:67px;height:63px;transform:translate(-50%,-50%);}
.chest-lid-hinge{position:absolute;left:0;top:0;transform-style:preserve-3d;transform-origin:0 0 -73px;transform:rotateX(0);transition:transform 1.7s cubic-bezier(.2,.7,.25,1);}
.chest-open .chest-lid-hinge{transform:rotateX(105deg);}
.chest-roof-strip{background:linear-gradient(90deg,#d79c29,#fff0a1 4%,#e8b849 8%,#73509e 9%,#9872c0 45%,#e8b545 47%,#ffed9b 50%,#e0a12e 53%,#73509e 55%,#8d68b4 91%,#e4ac37 92%,#fff1a4 96%,#c48b28);border-top:1px solid #a885b04d;border-bottom:1px solid #3f24564d;filter:brightness(var(--roof-light));}
.chest-lid-cap{left:-73px;top:-73px;width:146px;height:73px;border-radius:73px 73px 0 0;border:8px solid #e8b346;background:repeating-linear-gradient(90deg,transparent 0 24px,#3e205a4d 25px 27px),linear-gradient(#a586c9,#6d4a99);box-shadow:inset 0 0 0 2px #ffe89d;}
.chest-cap-left{transform:translateX(-125px) rotateY(-90deg);}
.chest-cap-right{transform:translateX(125px) rotateY(90deg);}
.chest-lid-underside{left:-125px;top:-73px;width:250px;height:146px;transform:rotateX(-90deg);border:8px solid #e1ad40;background:repeating-linear-gradient(90deg,transparent 0 31px,#a57cc43d 32px 34px),linear-gradient(#573773,#2e1b4a);box-shadow:inset 0 0 16px #150f34;}
.chest-lid-rail{left:-125px;top:-4px;width:250px;height:12px;border:2px solid #ffe493;background:linear-gradient(#fff3ae,#efbe4f,#ad7528);}
.chest-rail-front{transform:translateZ(73px);}.chest-rail-back{transform:translateZ(-73px) rotateY(180deg);}
.chest-loot{position:absolute;left:0;top:0;transform-style:preserve-3d;opacity:0;transition:opacity .4s .5s;}
.chest-open .chest-loot{opacity:1;}


.chest-glow{position:absolute;inset:-20% -15% 0;border-radius:50%;background:radial-gradient(ellipse,#fff3ab9c,transparent 65%);opacity:.3;pointer-events:none;}
.treasure-glowing .chest-glow{opacity:1;animation:chest-treasure-glow 2s ease-in-out infinite;}
@keyframes chest-treasure-glow{50%{opacity:.65;}}
/* Painted materials sit on the same solid faces; turning and hinge geometry stay intact. */
.chest-front,.chest-back,.chest-left,.chest-right{
 border:11px solid transparent;border-radius:7px;
 background:linear-gradient(120deg,#c7a2ff26,#170b453d) padding-box,url('assets/turtle-chest-wood-v2.png') center/250px 180px padding-box,linear-gradient(130deg,#fff6b0 0%,#eebd47 18%,#ad651b 35%,#ffdd71 49%,#fff3ad 56%,#d99422 78%,#855019 100%) border-box;
 box-shadow:inset 0 0 0 2px #ffe9a4,inset 0 0 15px #1a073ca6,0 0 0 1px #a66b24;
}
.chest-right,.chest-left{background-size:auto,180px 180px,auto;}
.chest-face::after{content:'';position:absolute;inset:5px;border:1px solid #e9c36d78;border-radius:5px;pointer-events:none;}
.chest-front::before,.chest-back::before{content:'';position:absolute;inset:0;background:linear-gradient(90deg,transparent 9%,#9a5e1d 9%,#ffdc78 10%,#fff3b2 12%,#d69529 14%,transparent 15%,transparent 85%,#976019 85%,#ffdf79 87%,#fff2a6 89%,#bb781f 91%,transparent 92%);}
.chest-rivet{width:10px;height:10px;border:1px solid #ac6c1f;box-shadow:inset 1px 1px 1px #fffbd5,0 2px 2px #392448a6;}
.chest-emblem{width:83px;height:78px;filter:drop-shadow(0 3px 2px #21103299);}
.chest-roof-strip{background:linear-gradient(90deg,#a26921,#ffdb74 3%,#fff4b4 5%,#d79b2c 8%,transparent 9%,transparent 45%,#9e631d 46%,#f4c458 48%,#fff1ab 50%,#e5a432 53%,transparent 55%,transparent 91%,#e4ac37 92%,#fff1a4 96%,#9d6320),url('assets/turtle-chest-wood-v2.png');background-size:100% 100%,250px 230px;background-position:0 0,0 var(--wood-y);}
.chest-lid-cap{border-color:#f1c45d;background:linear-gradient(130deg,#cfa8ff33,#25123e44),url('assets/turtle-chest-wood-v2.png') center/146px 160px;box-shadow:inset 0 0 0 2px #fff1ad,inset 0 0 12px #20103e,0 0 0 1px #a97026;}
.chest-lid-underside{border:10px solid transparent;background:radial-gradient(ellipse at 50% 40%,#6a3788,#291136) padding-box,linear-gradient(120deg,#fff2a8,#c48925 30%,#ffe391 60%,#a66b24) border-box;box-shadow:inset 0 0 0 2px #e7bc68,inset 0 0 24px #190623;}
.chest-lid-underside::after{content:'';position:absolute;inset:12px;border:2px solid #b48a4b;border-radius:18px;box-shadow:inset 0 0 0 3px #3d204c,0 0 0 1px #efcf8055;background:radial-gradient(ellipse at center,#b78a3326,transparent 65%);}
.chest-jewel-mound{position:absolute;left:-121px;top:-100px;width:242px;height:121px;object-fit:contain;transform:translateZ(28px);backface-visibility:hidden;}
.chest-jewel-sparkle{position:absolute;left:var(--sparkle-x);top:var(--sparkle-y);width:12px;height:17px;background:#fff9d8;clip-path:polygon(50% 0,62% 37%,100% 50%,62% 62%,50% 100%,38% 62%,0 50%,38% 37%);transform:translateZ(32px);animation:chest-jewel-twinkle 2.2s ease-in-out infinite;}
@keyframes chest-jewel-twinkle{0%,100%{opacity:.2;scale:.5;}45%{opacity:1;scale:1.15;}}
@media(prefers-reduced-motion:reduce){.chest-volume,.chest-lid-hinge{transition:none;}.treasure-glowing .chest-glow{animation:none;}}
@media(prefers-reduced-motion:reduce){.chest-jewel-sparkle{animation:none;}}
