/* Quest clear banner: diamond tiles spelling QUEST CLEAR over the board, with confetti. */
.quest-clear{position:absolute;inset:0;z-index:4;display:flex;align-items:center;justify-content:center;pointer-events:auto;cursor:pointer;overflow:hidden;background:radial-gradient(ellipse at 50% 45%,#ffffff22,transparent 60%)}
.clear-words{display:flex;flex-direction:column;align-items:center;gap:18px;transform:translateY(-8%)}
.clear-word{display:flex;gap:14px}
.clear-tile{position:relative;display:grid;place-items:center;width:52px;height:52px;font-style:normal;animation:clear-tile-in .5s calc(var(--n)*.045s) cubic-bezier(.2,1.4,.4,1) both}
.clear-tile::before{content:'';position:absolute;inset:0;background:#1f2c3f;transform:rotate(45deg) scale(.95);box-shadow:0 3px 0 #0e1522}
.clear-tile:nth-child(even)::before{background:#f4c34a}.clear-tile:nth-child(3n)::before{background:#fff}
.clear-tile b{position:relative;font-size:40px;line-height:1;font-weight:900;color:var(--c);text-shadow:0 2px 0 #0004;font-family:inherit}
.clear-words.failed .clear-tile::before{background:#3b2e44}.clear-words.failed .clear-tile:nth-child(even)::before{background:#8b6a8f}.clear-words.failed .clear-tile:nth-child(3n)::before{background:#d6c3d8}
.clear-confetti{position:absolute;inset:0;pointer-events:none}
.clear-confetti i{position:absolute;left:calc(8% + var(--n)*2.4%);top:38%;width:7px;height:7px;background:var(--c);transform:rotate(45deg);opacity:0;animation:clear-burst 1.3s calc(var(--n)*.012s) ease-out both}
.clear-confetti i:nth-child(odd){border-radius:50%;width:5px;height:5px}
@keyframes clear-tile-in{0%{opacity:0;transform:scale(.2) rotate(-30deg)}100%{opacity:1;transform:none}}
@keyframes clear-burst{0%{opacity:0;transform:translate(0,0) rotate(0)}15%{opacity:1}100%{opacity:0;transform:translate(calc((var(--n) - 18)*7px),calc(-90px + mod(var(--n),5)*60px)) rotate(300deg)}}
@media(max-width:400px){.clear-tile{width:42px;height:42px}.clear-tile b{font-size:32px}.clear-word{gap:10px}}

/* While the banner plays the mounted sheet stays invisible and untouchable. */
.battle-overlay.clearing{opacity:0;pointer-events:none}
.battle-overlay{transition:opacity .35s}
/* QUEST RESULT sheet: score breakdown, time multiplier, rank ladder, party sprites and reward panels. */
.battle-overlay.victory{background:linear-gradient(#3f8d4bcc,#2c6b45d9),url('forest.png') center/cover;backdrop-filter:blur(6px);padding:16px 14px 20px}
.battle-overlay:not(.victory){padding:16px 14px 20px}
.result-sheet{max-width:380px;gap:10px;align-items:stretch}
.result-sheet>small{align-self:center;color:#fff6d2;letter-spacing:4px;font-size:10px}
.victory .result-sheet>small{border:0;padding:0;font-weight:700}
.result-sheet h2{margin:0;text-align:center;font-size:30px;letter-spacing:3px;font-weight:900;color:#f9d65a;text-shadow:0 2px 0 #b98212,0 0 18px #ffe89a88,0 4px 8px #0006;font-family:inherit}
.victory h2{color:#f9d65a;text-shadow:0 2px 0 #b98212,0 0 18px #ffe89a88,0 4px 8px #0006;animation:clear-enter .55s both}
.result-board{display:grid;grid-template-columns:minmax(0,1fr) 108px;gap:10px;background:#fff;border-radius:8px;padding:12px 12px 14px;color:#33505f;box-shadow:0 4px 0 #0002;text-align:left}
.result-main{display:flex;flex-direction:column;gap:8px;min-width:0}
.result-table-wrap{max-height:158px;overflow-y:auto;border:1px solid #d9e3e8;border-radius:4px;scrollbar-width:thin}
.result-table{width:100%;border-collapse:collapse;font-size:12px}
.result-table td{padding:5px 8px;border-bottom:1px solid #e6edf1;white-space:nowrap}
.result-table td:last-child{text-align:right;font-weight:700;color:#274a5d;font-variant-numeric:tabular-nums}
.result-table tr:last-child td{border-bottom:0}
.result-time{display:flex;align-items:center;justify-content:space-between;font-size:14px;font-weight:700;color:#334e5c;font-variant-numeric:tabular-nums}
.result-mult{background:linear-gradient(#ffa63a,#f5801d);color:#fff;font-size:15px;padding:2px 12px;border-radius:2px;letter-spacing:1px;box-shadow:0 2px 0 #c7601a}
.result-score{display:flex;align-items:center;justify-content:flex-end;gap:8px;flex-wrap:wrap}
.result-score>b{font-size:30px;line-height:1;color:#f08a1e;font-variant-numeric:tabular-nums;text-shadow:0 2px 0 #fff, 0 3px 0 #d9c9a8}
.result-chips{display:flex;gap:6px;justify-content:flex-end;flex-wrap:wrap}
.result-chip{font-size:10px;letter-spacing:1px;background:#e3f6fa;color:#1e7f97;border:1px solid #9edcea;border-radius:2px;padding:3px 8px;font-weight:700}
.result-chip.new-record{background:#f5801d;color:#fff;border-color:#f5801d;clip-path:polygon(0 0,100% 0,94% 100%,0 100%)}
.rank-bar{position:relative;height:10px;margin:22px 4px 6px;border-radius:5px;background:#e9eef1;border:1px solid #d0dbe1}
.rank-fill{position:absolute;left:0;top:0;bottom:0;border-radius:5px;background:linear-gradient(90deg,#e64a3b,#f59a2a 55%,#ffd23a);box-shadow:0 0 6px #f6a53b88}
.rank-stop{position:absolute;top:-19px;transform:translateX(-50%);font-size:11px;font-weight:900;color:#b9c4cb;font-family:inherit;font-style:italic}
.rank-stop::after{content:'';position:absolute;left:50%;top:15px;width:2px;height:12px;background:currentColor;opacity:.5}
.rank-stop.reached{color:#f08a1e}
.result-side{display:flex;flex-direction:column;align-items:center;justify-content:space-between;gap:8px}
.result-sprites{display:flex;flex-wrap:wrap;justify-content:center;gap:0 2px;width:100%}
.result-sprite canvas{width:44px;height:44px;image-rendering:pixelated}
.result-sprite.down{opacity:.4;filter:grayscale(1)}
.result-sprite:nth-child(2){transform:translateY(-6px)}
.victory .result-rank{width:92px;height:92px;border:3px double #f4c65a;background:radial-gradient(#fff9e4,#fff);color:#f4c65a;font-size:44px;box-shadow:0 0 0 3px #f4c65a33;text-shadow:none;font-family:inherit;font-style:italic;font-weight:bold;display:grid;place-items:center;border-radius:50%;padding:0;align-self:center}
.battle-overlay:not(.victory) .result-rank{width:80px;height:80px;font-size:34px;color:#9fb1bb;border:3px double #c5d2d9;border-radius:50%;display:grid;place-items:center;padding:0;text-shadow:none;background:#f6f9fa}
.battle-overlay:not(.victory) .result-board{background:#f4f8fa}
.result-details{color:#eaf6f0;font-size:11px;border-top:0;padding-top:0}.result-details summary{color:#eaf6f0}
.reward-panel{background:#fff;border-radius:8px;padding:10px 12px 12px;box-shadow:0 4px 0 #0002;color:#33505f;text-align:left}
.reward-panel h4{display:inline-block;margin:0 0 8px;font-size:12px;letter-spacing:1px;color:#fff;background:#25404f;padding:3px 14px 3px 12px;clip-path:polygon(0 0,100% 0,92% 100%,0 100%);border-left:4px solid #f08a1e}
.reward-panel.first h4{background:#25404f}
.reward-items{display:flex;justify-content:center;gap:24px;padding:4px 0}
.reward-item{display:flex;flex-direction:column;align-items:center;gap:3px;font-size:11px;color:#44606e}
.reward-item .reward-icon{width:56px;height:56px;font-size:30px;border-radius:10px;background:radial-gradient(circle at 50% 30%,#fff,#fff3c4 70%,#ffe89a);box-shadow:0 0 0 3px #fff,0 0 18px #ffe07a}
.reward-item b{font-size:13px;color:#2b4a5c}.reward-item small{font-size:9px;letter-spacing:1px;color:#7b95a3}
.reward-panel .result-levels{color:#44606e;font-size:11px;margin:0;text-align:left}
.result-cta.ok-btn{display:flex;flex-direction:column;align-items:center;gap:2px;min-height:56px;border-radius:30px;background:linear-gradient(#5fd6de,#2fb7c8);border-color:#8fe6ec;box-shadow:0 4px 0 #1f8e9d;font-size:18px;letter-spacing:2px;padding:8px 18px;margin:6px 0 0}
.result-cta.ok-btn small{font-size:11px;letter-spacing:0;font-weight:600;color:#ecfdff}
.victory .result-board,.victory .reward-panel,.victory .result-cta{animation:clear-enter .5s .15s both}
.gentle .result-board,.gentle .reward-panel,.gentle .result-cta{animation:none}
@media(max-width:400px){.result-board{grid-template-columns:minmax(0,1fr) 92px;padding:10px}.victory .result-rank{width:78px;height:78px;font-size:36px}.result-sprite canvas{width:38px;height:38px}.result-score>b{font-size:26px}.result-sheet h2{font-size:26px}.result-table-wrap{max-height:132px}}

/* Compact layout: the whole result fits a 375x667 phone without scrolling. */
.battle-overlay.victory,.battle-overlay:not(.victory){padding:8px 12px 10px;justify-content:center}
.result-sheet{gap:6px}
.result-sheet>small{font-size:9px;letter-spacing:3px}
.result-sheet h2{font-size:22px;letter-spacing:2px}
.result-board{grid-template-columns:minmax(0,1fr) 96px;gap:8px;padding:8px 10px 10px}
.result-main{gap:5px}
.result-table-wrap{max-height:96px}
.result-table{font-size:11px}.result-table td{padding:3px 7px}
.result-time{font-size:13px}.result-mult{font-size:13px;padding:1px 10px}
.result-score>b{font-size:26px}.result-chip{font-size:9px;padding:2px 6px}
.rank-bar{height:8px;margin:18px 4px 4px}.rank-stop{top:-17px;font-size:10px}.rank-stop::after{top:14px;height:10px}
.result-sprite canvas{width:36px;height:36px}
.victory .result-rank{width:72px;height:72px;font-size:34px}
.battle-overlay:not(.victory) .result-rank{width:64px;height:64px;font-size:28px}
.reward-row{display:flex;gap:6px;width:100%}
.reward-panel{flex:1;min-width:0;padding:6px 8px 8px}
.reward-panel h4{font-size:10px;margin:0 0 5px;padding:2px 10px 2px 8px;letter-spacing:.5px}
.reward-items{gap:12px;padding:0}
.reward-item{font-size:10px;gap:1px}.reward-item .reward-icon{width:36px;height:36px;font-size:20px;border-radius:8px;box-shadow:0 0 0 2px #fff,0 0 10px #ffe07a}
.reward-item b{font-size:12px}.reward-item small{font-size:8px}
.result-sheet>.result-levels{margin:0;font-size:10px;line-height:1.5;color:#fff6d2;text-align:center}
.result-cta.ok-btn{min-height:46px;font-size:16px;padding:5px 16px;margin:2px 0 0;gap:0}
.result-cta.ok-btn small{font-size:10px}
.result-cta:not(.ok-btn){min-height:44px;margin:2px 0 0}
.result-secondary{gap:6px}.result-secondary button{min-height:34px;font-size:12px;padding:6px 10px}
@media(max-width:400px){.result-board{grid-template-columns:minmax(0,1fr) 84px;padding:8px}.victory .result-rank{width:64px;height:64px;font-size:30px}.result-sprite canvas{width:32px;height:32px}.result-score>b{font-size:24px}.result-sheet h2{font-size:20px}.result-table-wrap{max-height:84px}}
