/* Castle victory stays on the real final battlefield, beneath a borderless result. */
html:has(#dialog:not(.mother-modal)[open][data-kind="castlevictory"]),body:has(#dialog:not(.mother-modal)[open][data-kind="castlevictory"]){overflow:hidden;overscroll-behavior:none}
#dialog:not(.mother-modal)[data-kind="castlevictory"]{position:fixed;inset:0;box-sizing:border-box;margin:0;padding:0;width:100vw;height:100vh;height:100dvh;max-width:none;max-height:none;border:0;border-radius:0;box-shadow:none;background:#819568;color:#fff4ca;overflow:hidden;overscroll-behavior:contain}
#dialog:not(.mother-modal)[data-kind="castlevictory"]::backdrop{background:#1a2b23}
#dialog:not(.mother-modal)[data-kind="castlevictory"]>.close{display:none}
#dialog:not(.mother-modal)[data-kind="castlevictory"] #dialogBody:not(.mother-body){width:100%;height:100%;min-height:0}
.castle-victory{position:relative;isolation:isolate;height:100%;min-height:0;display:grid;place-items:center;padding:max(24px,env(safe-area-inset-top)) max(18px,env(safe-area-inset-right)) max(24px,env(safe-area-inset-bottom)) max(18px,env(safe-area-inset-left));box-sizing:border-box;overflow:auto;overscroll-behavior:contain}
#castleVictoryCanvas,.castle-victory-shade{position:fixed;inset:0;width:100%;height:100%;pointer-events:none}
#castleVictoryCanvas{z-index:-3}
.castle-victory-shade{z-index:-2;background:linear-gradient(#1a2c2645,#12251cc2 45%,#10241cd9 69%,#14281db3);animation:castle-victory-veil .65s ease-out both}
.castle-victory-content{width:min(100%,450px);text-align:center;position:relative;margin:auto;animation:castle-victory-appear .55s .12s cubic-bezier(.16,.8,.25,1.15) both}
.castle-victory-emblem{position:relative;display:grid;place-items:center;margin:0 auto 12px;width:110px;height:116px;isolation:isolate}
.castle-victory-emblem>svg{width:96px;height:102px;filter:drop-shadow(0 4px 0 #293e25) drop-shadow(0 0 25px #e9bd6460);animation:castle-victory-crest .8s cubic-bezier(.18,.8,.25,1.15) both}
.castle-victory-rays{position:absolute;z-index:-1;width:440px;height:440px;background:repeating-conic-gradient(from 0deg,#f4d7773c 0 8deg,transparent 8deg 30deg);border-radius:50%;mask-image:radial-gradient(circle,#000 10%,#0008 32%,transparent 65%);animation:castle-victory-rays 5s ease-out both}
.castle-victory-content h2{margin:0;color:#ffecad;font-size:clamp(32px,9vw,44px);line-height:1.17;text-shadow:0 3px 0 #61522b,0 7px 16px #081c1a66;font-weight:900;letter-spacing:.025em}
.castle-victory-unlocked{color:#e5eccd;font-size:18px;line-height:1.4;margin:12px 0 0;font-weight:700}
.castle-victory-loot{margin:30px 0 26px}
.castle-victory-loot>p{color:#cdd8bb;font-size:14px;font-weight:700;margin:0 0 14px}
.castle-victory-loot .castle-rewards{display:flex;align-items:center;justify-content:center;gap:14px 18px;flex-wrap:wrap;padding:0;background:none}
.castle-victory-loot .castle-rewards>span{display:inline-flex;align-items:center;gap:5px;white-space:nowrap;font-size:20px;color:#fff6d8;font-variant-numeric:tabular-nums;text-shadow:0 2px 2px #10271b}
.castle-victory-loot .castle-rewards svg{width:29px;height:29px;filter:drop-shadow(0 2px 1px #14281b55)}
.castle-victory-loot>small{display:block;margin-top:14px;color:#d2d7b9;font-size:12px}
.castle-victory-content>.primary:not(.mother-btn){width:100%;min-height:54px;font-size:19px;padding:12px;border-radius:14px;border:1px solid #d5e3a955;box-shadow:0 5px 0 #243e22,0 7px 24px #10271a66}
.castle-victory-sparks{position:absolute;inset:0;pointer-events:none;z-index:-1}
.castle-victory-sparks>i{position:absolute;left:50%;top:50%;width:7px;height:10px;border-radius:1px;background:#f2d68c;border:1px solid #fff3b9;opacity:0;animation:castle-victory-spark 1.2s calc(.22s + var(--victory-delay)) ease-out both;box-shadow:0 0 9px #e8c47766}
.castle-victory-sparks>i:nth-child(3n){background:#a9c784;width:5px;height:8px}
@keyframes castle-victory-appear{from{opacity:0;transform:translateY(17px) scale(.86)}to{opacity:1;transform:none}}
@keyframes castle-victory-crest{0%{transform:scale(.45) rotate(-8deg)}55%{transform:scale(1.12) rotate(3deg)}100%{transform:scale(1) rotate(0)}}
@keyframes castle-victory-rays{0%{opacity:0;transform:rotate(-20deg) scale(.3)}25%{opacity:1}100%{opacity:.75;transform:rotate(16deg) scale(1)}}
@keyframes castle-victory-veil{from{opacity:0}to{opacity:1}}
@keyframes castle-victory-spark{0%{opacity:0;transform:rotate(var(--victory-angle)) translateY(-24px) rotate(0) scale(.3)}20%{opacity:1}100%{opacity:0;transform:rotate(var(--victory-angle)) translateY(-220px) rotate(160deg) scale(.6)}}
@media(max-width:350px){.castle-victory-loot .castle-rewards{gap:11px 13px}.castle-victory-loot .castle-rewards>span{font-size:18px}.castle-victory-loot .castle-rewards svg{width:25px;height:25px}.castle-victory-content h2{font-size:32px}}
@media(max-height:600px){.castle-victory-emblem{height:85px;width:85px;margin-bottom:7px}.castle-victory-emblem>svg{width:73px;height:78px}.castle-victory-content h2{font-size:30px}.castle-victory-unlocked{font-size:16px;margin-top:8px}.castle-victory-loot{margin:18px 0}.castle-victory-loot>p{margin-bottom:9px}.castle-victory-content>.primary:not(.mother-btn){min-height:47px;font-size:17px}}
@media(max-height:420px){.castle-victory{padding-top:16px;padding-bottom:18px;place-items:start center}.castle-victory-emblem{height:58px;margin-bottom:4px}.castle-victory-emblem>svg{width:55px;height:58px}.castle-victory-content h2{font-size:27px}.castle-victory-loot{margin:14px 0}.castle-victory-unlocked{font-size:14px;margin-top:6px}}
@media(prefers-reduced-motion:reduce){.castle-victory *{animation:none!important}.castle-victory-sparks{display:none}}
