.treasure-toggle{justify-self:end;display:flex;align-items:center;gap:9px;min-height:64px;padding:4px 15px 4px 8px;border:1px solid #bfa56c;border-radius:18px 18px 23px 18px;background:#235e50;color:#fff7df;box-shadow:inset 0 0 0 3px #235e50,inset 0 0 0 4px #a78f5f,0 3px 7px #204b4020;cursor:pointer;text-align:left;line-height:1.2;transition:background .16s,box-shadow .16s}
.treasure-toggle img{display:block;width:58px;height:54px;flex:none}
.treasure-button-label{display:grid;justify-items:start;gap:5px;white-space:nowrap;font-size:13px;font-weight:650;letter-spacing:.01em}
.treasure-toggle strong{display:block;min-width:43px;padding:2px 8px;border:1px solid #b8a471;border-radius:7px;background:#173f36;color:#f4ddb0;font-size:12px;font-weight:650;font-variant-numeric:tabular-nums;text-align:center;letter-spacing:.09em}
.treasure-toggle:hover{background:#2b6c5c;box-shadow:inset 0 0 0 3px #2b6c5c,inset 0 0 0 4px #d1ba7d,0 4px 9px #204b4029}
.treasure-toggle:focus-visible{outline:3px solid #8b3d5c;outline-offset:3px}
.treasure-toggle:active{background:#1c4e42}
.treasure-dialog{width:min(760px,calc(100% - 24px));max-height:90dvh;padding:24px;border:1px solid #8aa79b;border-radius:24px;background:var(--paper);color:var(--ink);box-shadow:var(--shadow);overflow:auto;overscroll-behavior:contain;}
.treasure-dialog::backdrop{background:#153a46a6}.treasure-dialog h2{font-size:26px;margin:0}.treasure-dialog h3{font-size:20px;margin:22px 0 10px}.treasure-dialog p{margin:10px 0;max-width:62ch}.treasure-close{float:right;min-height:44px;padding:8px 14px}.treasure-dialog button{color:var(--ink);background:#fffdf7;border:1px solid #91aca1;border-radius:10px;padding:9px 13px;min-height:44px;cursor:pointer}.treasure-dialog button:hover{background:#deeee6}.treasure-dialog button:disabled{opacity:.55;cursor:default}.gem-tray{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;margin:22px 0}.gem-tray-slot{border:1px solid #bed0c1;border-radius:16px;background:#e9efe6;min-height:124px;display:flex;align-items:center;justify-content:center;flex-direction:column;text-align:center;padding:8px;font-size:12px}.gem-tray-slot svg{width:86px;height:78px;overflow:visible}.gem-tray-slot.empty{border-style:dashed;color:#557069;font-size:23px}.gem-levels{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.gem-levels button{text-align:left}.gem-levels strong,.gem-levels span{display:block}.gem-levels span{font-size:12px;margin-top:4px}.gem-levels button[aria-pressed=true]{background:#d1e8da;border:2px solid #267969;padding:8px 12px}.gem-puzzle-help{font-size:13px;color:#405d59}.gem-board{display:block;width:100%;max-height:68dvh;touch-action:none;user-select:none;border:1px solid #a3baab;border-radius:18px}.gem-piece{cursor:grab;outline:none}.gem-piece:active{cursor:grabbing}.gem-selection{opacity:0}.gem-piece.is-selected .gem-selection,.gem-piece:focus-visible .gem-selection{opacity:1}.gem-piece.is-placed{cursor:default}.gem-piece.is-placed .gem-selection{stroke:#f9fff8;stroke-width:2}.gem-tools{display:flex;gap:10px;flex-wrap:wrap;margin-top:12px}.gem-result{font-weight:700;color:#176351}.gem-board.is-solved{background:#deeee1;border-color:#46836a}.treasure-layer{position:absolute;inset:0;pointer-events:none;z-index:35}.scene-gem{position:absolute;width:48px;height:48px;transform:translate(-50%,-50%);border:0;background:none;padding:0;pointer-events:auto;cursor:pointer;filter:drop-shadow(0 2px 2px #163b4566)}.scene-gem svg{width:48px;height:48px;overflow:visible}.scene-gem:focus-visible{outline:3px solid #8b3d5c;border-radius:50%}.treasure-notice{grid-area:1/1;justify-self:start;width:fit-content;max-width:100%;box-sizing:border-box;padding:8px 12px;border:1px solid #a8c1b2;border-left:3px solid #4a8b74;border-radius:12px;background:#edf5ed;color:#214a41;font-size:13px;line-height:1.4;text-align:left;pointer-events:none}.treasure-notice[hidden]{display:none}.gem-notice-slot{display:grid;align-items:center;min-height:52px}.gem-notice-slot>h2{grid-area:1/1}.gem-notice-slot.has-gem-notice>h2{opacity:0}.canopy-gem-cache{position:absolute;right:-4px;top:1%;width:clamp(116px,27%,178px);aspect-ratio:180/108;padding:0;border:0;background:none;pointer-events:auto;cursor:pointer}.canopy-gem-cache svg{display:block;width:100%;height:100%}.canopy-gem-cache:focus-visible{outline:3px solid #fff3b5;outline-offset:-8px;border-radius:35%}.canopy-gem-cache:disabled{cursor:default}.scene-gem[data-treasure-gem="towel"]::after{content:"";position:absolute;left:11px;right:11px;bottom:2px;height:4px;border-radius:50%;background:#233b3629;z-index:-1}.telescope-view{background:#172e3e;border:8px solid #bfa36e;border-radius:50%;width:min(280px,70vw);aspect-ratio:1;margin:18px auto;position:relative;overflow:hidden;background-image:radial-gradient(circle at 21% 30%,#f5edca 0 1px,transparent 2px),radial-gradient(circle at 76% 21%,#f5edca 0 1px,transparent 2px),radial-gradient(circle at 65% 75%,#f5edca 0 1px,transparent 2px),radial-gradient(ellipse at 35% 60%,#396170,transparent 60%)}.telescope-spark{position:absolute;inset:25%;filter:blur(9px);transition:filter .35s}.telescope-spark svg{width:100%;height:100%}.telescope-view.is-focused .telescope-spark{filter:none}.treasure-save-note{font-size:12px;color:#47635d}.treasure-dialog [hidden]{display:none!important}
@media(max-width:520px){.treasure-dialog{padding:16px}.gem-tray{gap:6px}.gem-tray-slot{min-height:94px;padding:4px;font-size:10px}.gem-tray-slot svg{width:58px;height:62px}.gem-levels{gap:5px}.gem-levels button{padding:8px 7px;font-size:13px}.gem-levels button[aria-pressed=true]{padding:7px 6px}.gem-board{max-height:none}}
@media(prefers-reduced-motion:reduce){.telescope-spark{transition:none}}
.treasure-dialog:has(.gem-board)>.treasure-content>.treasure-save-note{margin-top:6px}
.gem-board{width:min(100%,max(280px,calc((90dvh - 305px)*.923)));height:auto;max-height:none;margin-inline:auto}
@media(max-width:520px){.gem-board{width:100%}}
.treasure-close{min-width:44px;padding:3px 10px!important;font-size:26px}
.treasure-dialog:has(.gem-board)>.treasure-content>p:not(.treasure-save-note),.treasure-dialog:has(.gem-board) .gem-assembly>h3{display:none}
.treasure-dialog:has(.gem-board) .gem-levels{clear:both;padding-top:14px}
@media(max-width:520px){.treasure-dialog h2{font-size:20px;line-height:1.3;padding-top:8px}.gem-levels span{font-size:11px;line-height:1.3}.gem-puzzle-help{font-size:12px;line-height:1.4}.gem-tools button{padding:7px 9px;font-size:12px}}

@media(max-width:520px){.gem-notice-slot{min-height:72px}.treasure-notice{font-size:12px;padding:8px 10px}}

/* A fitted jewel case, with the collected stones always on display. */
.treasure-dialog{border-color:#b79c68;box-shadow:inset 0 0 0 5px #fff9e9,inset 0 0 0 6px #d9c799,0 18px 48px #153c3b38;background:#fcf9ed}
.treasure-dialog{overflow:hidden}
.treasure-dialog[open]{display:flex;flex-direction:column;gap:14px}
.treasure-header{display:flex;align-items:center;justify-content:space-between;gap:16px;flex:none;padding-bottom:12px;border-bottom:1px solid #d9c799}
.treasure-header h2{padding:0;min-width:0}
.treasure-header .treasure-close{position:static;float:none;flex:none;display:grid;place-items:center;width:44px;height:44px;line-height:1;background:#fff9eb!important}
.treasure-content{min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable;padding:0 4px 6px 0}
.treasure-content>.gem-tray{margin-top:0}
.gem-tray{gap:8px;margin:18px 0}
.gem-tray-slot{background:#f5f0dd;border-color:#d1bf94;box-shadow:inset 0 1px 0 #fffdf5;min-height:106px;border-radius:13px 13px 18px 18px;color:#36594f}
.gem-tray-slot svg{filter:drop-shadow(0 3px 2px #4b4b3324)}
.gem-levels{padding:6px!important;border:1px solid #cdbb91;border-radius:16px;background:#f1ebd9;gap:6px}
.gem-levels button{text-align:center;background:#fffaf0;border-color:transparent;border-radius:11px}
.gem-levels button[aria-pressed=true]{background:#255f51;color:#fff8e7;border-color:#d4bd7d;box-shadow:0 2px 4px #143d3420}
.gem-board{width:min(100%,460px);border:0;border-radius:24px;background:#b99a60;box-shadow:0 7px 17px #173d3524}
.gem-board.is-solved{background:#b99a60}
.gem-board .gem-selection{stroke:#fff4b7;stroke-width:3}
.gem-board .gem-piece:focus-visible .gem-selection{stroke:#fff4b7;stroke-width:4}
.gem-tools{justify-content:center}
.gem-tools button{border-color:#bbaa7d;border-radius:12px;background:#fffaf0}
.gem-result:empty{display:none}
.gem-assembly.is-complete .gem-puzzle-help{visibility:hidden}
.gem-assembly.is-complete .gem-result{max-width:none;text-align:center;padding:12px 14px;border:1px solid #cfb978;border-radius:14px;background:#edf2df;color:#255748}
@media(max-width:520px){.gem-tray{gap:6px}.gem-tray-slot{min-height:90px}.gem-tray-slot svg{width:54px;height:54px}.gem-board{width:100%;border-radius:16px}.gem-levels{padding:4px!important;gap:4px}}

.gem-contact-shadow{opacity:.25}
.gem-piece.is-placed .gem-contact-shadow{opacity:.16}

@media(max-width:680px){.treasure-toggle{min-height:56px;padding:3px 12px 3px 6px;gap:7px}.treasure-toggle img{width:48px;height:46px}.treasure-button-label{font-size:12px;gap:3px}.treasure-toggle strong{font-size:11px;padding:2px 7px}}
@media(prefers-reduced-motion:reduce){.treasure-toggle{transition:none}}

.treasure-restart{display:block;margin:18px auto 0;background:transparent!important;color:#664655;border-color:#c9bca5!important;font-size:13px}
.treasure-restart:disabled{opacity:.5;cursor:default}
.treasure-restart-confirmation{margin-top:12px;padding:14px;border:1px solid #d9c799;border-radius:12px;background:#f5efdf}
.treasure-restart-confirmation p{margin:0;font-size:14px;line-height:1.5}
.treasure-restart-actions{display:flex;flex-wrap:wrap;gap:10px;margin-top:12px}
.treasure-restart-actions button{min-height:44px}

/* Gems retain their scene scale; the transparent touch target stays generous. */
.scene-gem{display:grid;place-items:center;filter:drop-shadow(0 1px 1px #163b4540)}
.scene-gem svg{width:var(--scene-gem-size,32px);height:var(--scene-gem-size,32px)}
.scene-gem-shadow{position:absolute;height:4px;border-radius:50%;background:#172e2d;opacity:.22;transform:translate(-50%,-50%);pointer-events:none;filter:blur(1.5px)}
.scene-gem[data-treasure-gem="towel"]::after{content:none}
.scene-gem[hidden]{display:none}

/* A shared tray and quiet controls leave the fitted board as the centrepiece. */
.treasure-dialog{width:min(680px,calc(100% - 24px));border-radius:20px;box-shadow:0 18px 48px #153c3b38}
.treasure-dialog[open]{gap:10px}
.gem-tray{grid-template-columns:repeat(8,minmax(0,1fr));gap:4px;margin:0 0 10px;padding:4px 0 10px;border-bottom:1px solid #d9c799}
.gem-tray-slot{border:0;background:transparent;box-shadow:none;min-height:40px;padding:2px}
.gem-tray-slot svg{width:100%;max-width:52px;height:46px}
.gem-levels{display:flex;justify-content:center;gap:20px;padding:0!important;border:0;border-radius:0;background:transparent;margin-bottom:12px}
.gem-levels button,.gem-levels button[aria-pressed=true]{min-width:90px;background:transparent;color:#35554a;border:0;border-bottom:2px solid transparent;border-radius:0;padding:8px 12px;box-shadow:none}
.gem-levels button[aria-pressed=true]{border-bottom-color:#28634f;color:#174e3d}
.gem-assembly.is-complete .gem-result{padding:0;margin:6px 0 12px;border:0;background:transparent;font-size:14px;font-weight:500}
.gem-board{width:min(100%,460px,max(240px,calc((90dvh - 410px)*.923)))}
.gem-tools{margin-top:8px}
.gem-tools button,.treasure-restart{background:transparent;border:0!important;text-decoration:underline;text-underline-offset:4px}
.treasure-restart{margin-top:4px}
.gem-heart-touch{cursor:pointer;touch-action:none;outline:none}
.gem-heart-touch:focus-visible polygon{stroke:#fff6c8;stroke-width:3;stroke-linejoin:round}
.treasure-notice{position:absolute;top:12px;left:50%;transform:translateX(-50%);max-width:calc(100% - 24px);width:max-content;text-align:center;border:1px solid #a8c1b2;border-radius:9px;background:#f6faef;box-shadow:0 2px 5px #193e3320;padding:7px 12px}
@media(max-width:520px){.gem-tray-slot svg{height:34px}.gem-tray{padding-bottom:8px}.treasure-notice{top:8px;font-size:12px}.gem-levels{margin-bottom:8px}}

/* Keep the jewel close, with recognisable controls and no repeated title. */
.treasure-dialog.is-chest{width:min(720px,calc(100% - 16px));max-height:94dvh;padding:12px 16px 16px}
.treasure-dialog.is-chest .treasure-header{justify-content:flex-end;border:0;padding-bottom:0}
.treasure-dialog.is-chest .treasure-header h2{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}
.gem-levels{gap:8px}
.gem-levels button,.gem-levels button[aria-pressed=true]{min-width:96px;border:1px solid #b9b394;border-radius:9px;padding:8px 16px;background:#fffaf0}
.gem-levels button[aria-pressed=true]{background:#255f51;border-color:#255f51;color:#fff8e7;box-shadow:inset 0 1px 0 #ffffff24}
.gem-levels button:hover{background:#e4ece1;color:#174e3d}
.gem-levels button[aria-pressed=true]:hover{background:#2d6c5c;color:#fff8e7}
.gem-board,.gem-board.is-solved{background:transparent;border-radius:14px;box-shadow:0 4px 10px #173d3520}
.gem-board{width:min(100%,560px)}
.gem-board.is-solved{width:min(100%,560px)}
.gem-tools{margin-top:12px}
.gem-tools button,.treasure-restart{border:1px solid #b9b394!important;border-radius:9px;background:#fffaf0!important;padding:8px 16px;text-decoration:none}
.gem-tools button:hover,.treasure-restart:hover{background:#e4ece1!important}
.treasure-restart{margin-top:12px}
.gem-board.is-solved [data-heart-assembly]{transform-box:view-box}

@media(max-width:520px){.treasure-dialog.is-chest{padding-inline:10px}.treasure-dialog.is-chest .treasure-content{scrollbar-gutter:auto;padding-right:0}}

.treasure-dialog.is-chest .treasure-header{align-items:center;gap:12px;padding-bottom:10px;border-bottom:1px solid #d9c799}
.treasure-dialog.is-chest .treasure-header>.gem-tray{flex:1;min-width:0;margin:0;padding:0;border:0}

/* Completion keeps the same board, caption slot and controls in place. */
.gem-caption{display:grid;align-items:center;text-align:center}
.gem-caption>p,.gem-assembly.is-complete .gem-caption>.gem-result{grid-area:1/1;max-width:none;margin:10px 0;padding:0;border:0;background:transparent;font-size:13px;line-height:1.4}
.gem-restart-row{display:flex;align-items:center;justify-content:center;gap:8px;max-width:100%}
.gem-restart-row .treasure-restart{margin:0}
.gem-tools button{font-size:13px;white-space:nowrap}
@media(max-width:520px){.gem-tools{gap:8px}.gem-tools button{padding:8px 11px}}
