/* One depth-tested scene contains the glass, moulding and workbench light receiver. */
:root body #screen-game .restoration-frame.has-reward-scene {position:relative;isolation:isolate;border-color:transparent!important;border-image:none!important;box-shadow:none!important;color:oklch(94% .03 86);}
:root body #screen-game .restoration-frame.has-reward-scene::before {display:none!important;}
:root body #screen-game .has-reward-scene .reward-scene {position:absolute;inset:0;width:100%;height:100%;z-index:-1;pointer-events:none;border-radius:inherit;}
:root body #screen-game .has-reward-scene :is(#win-message,#puzzle-title,#tutorial-result-heading) {color:oklch(95% .035 86);text-shadow:0 2px 3px oklch(15% .025 165 / .6);}
:root body #screen-game .has-reward-scene #win-note {color:oklch(89% .03 85);}
:root body .glass-reward.has-unified-frame .reward-object > * {visibility:hidden!important;}
:root body .glass-reward.has-unified-frame .reward-object:focus-visible {outline:none;}
@media (prefers-reduced-motion:no-preference){
    :root body #screen-game .has-reward-scene .reward-scene {animation:reveal-workbench 540ms ease-out both;}
    @keyframes reveal-workbench {from{opacity:0}to{opacity:1}}
}
/* Input belongs to the stationary viewing area. A CSS 3D plane at exactly
   90 degrees can otherwise report hits beyond its projected bounds. */
:root body .glass-reward .reward-object {pointer-events:none!important;}
:root body .glass-reward:has(.reward-object.is-dragging) {cursor:grabbing;}
/* The no-WebGL alternative is an honest thin framed panel, without fake slabs. */
:root body .glass-reward :is(.reward-side,.reward-side-bottom,.reward-side-top) {display:none;}
:root body .glass-reward .reward-back {inset:0;background:transparent;transform:translateZ(-1px) rotateY(180deg);}
:root body .glass-reward .reward-back .reward-reverse {inset:0;width:100%;height:100%;}
:root body .glass-reward .reward-back .depth-frame {inset:-8.7%;width:117.4%;height:117.4%;}
/* A quiet visual invitation replaces a paragraph of instructions. */
:root body .glass-reward .reward-turn-cue {position:absolute;z-index:5;left:50%;bottom:5%;width:76px;height:26px;transform:translateX(-50%);color:#f5dfae;opacity:0;pointer-events:none;filter:drop-shadow(0 2px 3px #07120e);transition:opacity 300ms ease;}
:root body .glass-reward.reward-ready:not(.reward-interacted) .reward-turn-cue {opacity:.88;}
:root body .glass-reward .reward-turn-cue svg {display:block;width:100%;height:100%;fill:none;stroke:currentColor;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:round;}
@media (prefers-reduced-motion:reduce){:root body .glass-reward .reward-turn-cue {transition:none;}}

/* Gilded stars sit above the turning window, outside its interaction area. */
#win-rating {
    display: flex; justify-content: center; align-items: center; gap: 6px;
    width: max-content; margin: 6px auto 1px;
    filter: drop-shadow(0 2px 2px #17140f);
}
#win-rating[hidden] { display: none; }
.rating-star { display:inline-block; object-fit:contain; }
#win-rating .rating-star { width:26px; height:26px; }
#win-rating .rating-star:nth-child(2) { width:33px; height:33px; }
.result-count { display:inline-flex; align-items:center; gap:5px; vertical-align:middle;
    font:400 19px/1 var(--font-ui); letter-spacing:0; }
.result-count + .result-count { margin-inline-start:15px; }
.result-count .ui-icon,.result-count .mistake-icon { width:21px; height:21px; object-fit:contain; }
@media (max-height: 500px) {
    #win-rating { margin-top: 3px; }
    #win-rating .rating-star { width:22px; height:22px; }
    #win-rating .rating-star:nth-child(2) { width:28px; height:28px; }
}

/* A pair of little cut-glass glints frames a mistake-free finish. */
:root body.solved-phase-2 #screen-game #win-message.clean-solve {
    color: #ffe7aa; font-size: clamp(1.5rem, 4.8vw, 2rem);
}
:root body #screen-game #win-message.clean-solve::before,
:root body #screen-game #win-message.clean-solve::after {
    content: ''; display: inline-block; vertical-align: .12em;
    width: .52em; height: .68em; margin-inline: .52em;
    background: linear-gradient(115deg, #fff3cb 40%, #d9a954 42%, #f6d991 80%);
    clip-path: polygon(50% 0, 63% 35%, 100% 50%, 63% 63%, 50% 100%, 36% 63%, 0 50%, 36% 35%);
}
@media (prefers-reduced-motion: no-preference) {
    #win-message.clean-solve::before, #win-message.clean-solve::after {
        animation: reward-glint 650ms cubic-bezier(.2,.7,.2,1) both;
    }
    #win-message.clean-solve::after { animation-delay: 90ms; }
    @keyframes reward-glint {
        0% { opacity: 0; scale: .3; }
        60% { opacity: 1; scale: 1.22; }
        100% { opacity: 1; scale: 1; }
    }
}

/* The finished piece hangs over the same oiled board that receives its light. */
:root[data-theme] body.screen-game-active[data-depth-reward],
:root[data-theme] body[data-depth-reward] #screen-game,
:root[data-theme] body[data-depth-reward] #screen-game .restoration-frame {
    background: #4e3524 url('assets/reward/workbench.webp') center / cover !important;
    border-image: none !important;
}
:root[data-theme] body #screen-game .restoration-frame.has-reward-scene::after {
    content: ""; display:block!important; position:absolute; z-index:0; inset:6px;
    width:auto; height:auto; pointer-events:none; opacity:1; border-radius:1px;
    background:none; transform:none;
    border:1px solid #b5915f60;
    box-shadow:0 0 0 1px #2319119c, inset 0 0 0 2px #22170f80, inset 0 0 0 3px #ad875c34;
}
:root[data-theme] body[data-depth-reward] #screen-game :is(#win-actions button,#tutorial-continue) {
    --plate:#34271e; --edge:#9e7950; --ink:#f0dfbb;
    position:relative; min-height:44px; padding:8px 16px; border-radius:3px;
    background:linear-gradient(165deg,#ffffff0d,transparent 50%,#130f0a32),var(--plate)!important;
    color:var(--ink)!important; border:1px solid var(--edge)!important;
    box-shadow:inset 0 0 0 2px var(--plate),inset 0 0 0 3px #ba985351,0 2px 2px #190f0c8c!important;
    font:600 14px/1.2 var(--font-display,Georgia),serif; letter-spacing:.018em;
    text-shadow:none!important; filter:none; transform:none;
}
:root[data-theme] body[data-depth-reward] #screen-game #win-actions #next-button,
:root[data-theme] body[data-depth-reward] #screen-game #tutorial-guide #tutorial-continue {
    --plate:#b6945e; --edge:#e3c392; --ink:#241a10;
}
:root[data-theme] body[data-depth-reward] #screen-game #victory-home {min-width:44px; padding:7px 12px;}
#victory-home .ui-icon {width:22px;height:22px;vertical-align:middle;}
/* Reserve the final layout while the window turns and the reward is collected. */
#screen-game .restoration-frame[data-victory-phase] #win-note {
    display:block; position:relative; min-height:36px; align-content:center;
}
#screen-game .restoration-frame:is([data-victory-phase="artwork"],[data-victory-phase="hammers"]) :is(#win-message,#win-rating,.reward-turn-cue) {visibility:hidden;}
#screen-game .restoration-frame:is([data-victory-phase="artwork"],[data-victory-phase="hammers"]) #win-actions {display:flex!important;visibility:hidden;}
@media (prefers-reduced-motion:no-preference) {
    #screen-game [data-victory-phase="results"] :is(#win-note,#win-rating,#win-actions,#win-message) {animation:show-victory-details 260ms ease-out both;}
    @keyframes show-victory-details {from{opacity:0}to{opacity:1}}
}
:root[data-theme] body[data-depth-reward] #screen-game :is(#win-actions button,#tutorial-continue)::before,
:root[data-theme] body[data-depth-reward] #screen-game :is(#win-actions button,#tutorial-continue)::after {
    content:"";position:absolute;top:50%;left:5px;right:auto;bottom:auto;inset-block-end:auto;
    width:3px;height:3px;border:0;border-radius:50%;transform:translateY(-50%);opacity:.85;
    background:linear-gradient(145deg,#eed2a0 32%,#4f3c24 37% 61%,#a98956 67%);
    pointer-events:none;box-shadow:0 1px 0 #271c12;animation:none;
}
:root[data-theme] body[data-depth-reward] #screen-game :is(#win-actions button,#tutorial-continue)::after {left:auto;right:5px;}
:root[data-theme] body[data-depth-reward] #screen-game :is(#win-actions button,#tutorial-continue):hover {--edge:#ecd2a4;}
:root[data-theme] body[data-depth-reward] #screen-game :is(#win-actions button,#tutorial-continue):active {translate:0 1px;}
:root[data-theme] body[data-depth-reward] #screen-game :is(#win-actions button,#tutorial-continue):focus-visible {outline:2px solid #fff2c7;outline-offset:3px;}
