#run-ending{border:0;padding:0;background:#102b24;color:#ffe3a0;width:min(390px,100vw);height:min(844px,100dvh);max-width:100vw;max-height:100dvh;margin:auto;overflow:hidden;outline:none}
#run-ending::backdrop{background:rgba(8,27,22,.86)}
.run-ending-stage{height:100%;position:relative;display:flex;flex-direction:column;isolation:isolate;background:var(--ending-field)}
.run-ending-stage::after{content:"";position:absolute;inset:0;border:12px solid transparent;border-image:url('assets/mockups/forest-frame-subtle.svg') 6 stretch;pointer-events:none;z-index:5}
.ending-forest{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;opacity:.5;z-index:-2}
.ending-dawn{position:absolute;inset:0;background:linear-gradient(#102b2470 0%,transparent 40%,#102b24 94%);z-index:-1}
.ending-heading{text-align:center;padding:clamp(24px,6vh,54px) 20px 0;flex:none}
#run-ending .ending-heading h2{color:#ffe3a0!important;font:700 clamp(23px,6vw,30px)/1.2 'Courier New',monospace;margin:0;text-shadow:0 2px 3px #102b24}
.ending-tableau{flex:1;min-height:0;position:relative;display:flex;align-items:flex-end;justify-content:center;padding-bottom:12px}
.ending-hero{position:relative;z-index:2;max-width:76%;height:70%;max-height:330px;object-fit:contain;filter:drop-shadow(0 5px 5px #102b24);animation:ending-hero-light 2.8s ease-out both}
.ending-core{position:absolute;top:3%;left:50%;width:100px;transform:translateX(-50%);color:#ffe3a0;z-index:3;animation:ending-light-return 2.8s ease-out both}
.ending-core svg{width:100%;height:auto;filter:drop-shadow(0 0 13px #efc969)}
.ending-halo{position:absolute;left:50%;top:34%;width:150px;transform:translateX(-50%);color:var(--ending-accent);opacity:.22;z-index:0}
.ending-halo svg{width:100%;height:100%}
.ending-motif{position:absolute;bottom:18%;left:calc(50% - 10px);width:20px;height:20px;opacity:0;z-index:3;animation:ending-motif-rise 2.8s ease-out both;animation-delay:calc(var(--i)*35ms);color:var(--ending-accent)}
.ending-motif svg{width:100%;height:100%}
.ending-caption{padding:16px 24px clamp(30px,6vh,52px);text-align:center;flex:none;background:linear-gradient(transparent,#102b24 30%);z-index:4}
.ending-name{display:flex;align-items:center;justify-content:center;gap:10px;color:var(--ending-accent);font:700 18px/1.3 'Courier New',monospace}
.ending-name svg{width:24px;height:24px;flex:none}
#run-ending .ending-caption p{font:15px/1.5 'Trebuchet MS',sans-serif;color:#f1e7c9!important;margin:12px auto 0;max-width:30ch}
#run-ending .ending-name strong{color:var(--ending-accent)!important}
#run-ending[data-outcome="lost"] .ending-dawn{background:linear-gradient(#102b2440,#102b24ee);animation:ending-darken 2.8s ease-out both}
#run-ending[data-outcome="lost"] .ending-hero{animation:ending-hero-dim 2.8s ease-out both}
#run-ending[data-outcome="lost"] .ending-core{animation:ending-light-fail 2.8s ease-out both}
#run-ending[data-outcome="lost"] .ending-halo{animation:ending-seal-fade 2.8s ease-out both}
#run-ending[data-outcome="lost"] .ending-motif{animation-name:ending-motif-fall}
#run-ending[data-hero="time"][data-outcome="won"] .ending-motif{animation-name:ending-time-spiral}
#run-ending[data-hero="stormcaller"][data-outcome="won"] .ending-halo{animation:ending-storm 2.8s ease-out both}
@keyframes ending-light-return{0%{opacity:.2}28%{opacity:1}65%{filter:drop-shadow(0 0 20px #ffe3a0)}100%{opacity:1}}
@keyframes ending-hero-light{from{filter:brightness(.55) drop-shadow(0 5px 5px #102b24)}to{filter:brightness(1.08) drop-shadow(0 5px 8px #c7a352)}}
@keyframes ending-light-fail{0%,15%{opacity:1}48%{opacity:.45}75%,100%{opacity:.08}}
@keyframes ending-hero-dim{from{filter:brightness(1) drop-shadow(0 5px 5px #102b24)}to{filter:brightness(.5) saturate(.55) drop-shadow(0 5px 5px #102b24)}}
@keyframes ending-darken{from{opacity:0}to{opacity:1}}
@keyframes ending-seal-fade{from{opacity:.3}to{opacity:.05}}
@keyframes ending-motif-rise{0%,12%{opacity:0;transform:translate(0,0)}35%{opacity:.8}100%{opacity:0;transform:translate(var(--x),calc(-1 * var(--rise)))}}
@keyframes ending-motif-fall{0%,10%{opacity:0;transform:translate(var(--x),-30px)}30%{opacity:.5}100%{opacity:0;transform:translate(var(--x),60px)}}
@keyframes ending-time-spiral{0%,12%{opacity:0;transform:translate(0,0) rotate(0)}35%{opacity:.8}100%{opacity:0;transform:translate(var(--x),calc(-1 * var(--rise))) rotate(-120deg)}}
@keyframes ending-storm{0%,24%{opacity:.06}30%{opacity:.45}45%{opacity:.15}70%{opacity:.3}100%{opacity:.22}}
#run-ending.ending-reduced .run-ending-stage *{animation:none!important}
#run-ending.ending-reduced[data-outcome="lost"] .ending-core{opacity:.08}
#run-ending.ending-reduced[data-outcome="lost"] .ending-hero{filter:brightness(.5) saturate(.55)}
#run-ending.ending-reduced .ending-motif{display:none}
@media(prefers-reduced-motion:reduce){#run-ending .run-ending-stage *{animation:none!important}.ending-motif{display:none}}
@media(max-height:600px){.ending-heading{padding-top:28px}.ending-caption{padding:10px 24px 28px}.ending-caption p{margin-top:8px}.ending-core{width:76px;top:0}.ending-hero{height:68%}.ending-name{font-size:16px}}
