/* Responsive, low-latency tactile puzzle interface */
.challenge{color:#e8ddcc;padding:4px 0 10px}
.challenge-help{font-size:14px;line-height:1.9;color:#c6b5a0;margin:0 0 17px}
.challenge-feedback{min-height:26px;font-size:12px;letter-spacing:.4px;color:#d8be8f}
.challenge button{touch-action:manipulation;-webkit-tap-highlight-color:transparent}
.tile-board,.pipes-board,.reflection-board{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:4px;width:min(100%,385px);margin:12px auto 16px;padding:7px;background:#070709;border:1px solid #b59c6c88;border-radius:3px;box-shadow:0 12px 38px #0007}
.tile-board{aspect-ratio:1}.picture-tile{background-size:300% 300%;background-repeat:no-repeat;aspect-ratio:1;border:2px solid #b49a6655;border-radius:1px;min-width:0;transition:border-color .08s,filter .08s;filter:sepia(.18)}
.picture-tile.selected{border:2px solid #eed8a3;filter:brightness(1.3);z-index:2;box-shadow:inset 0 0 12px #eed8a35a}
.picture-tile:active{filter:brightness(1.35)}
.pipes-board{aspect-ratio:1;width:min(100%,385px);padding:2px;gap:2px;background:#6e573d;border:1px solid #b59c6c88}
.pipe-empty,.pipe-piece,.pipe-terminal{min-height:0;min-width:0;aspect-ratio:1;display:grid;place-items:center;padding:0;border:1px solid transparent;background:radial-gradient(ellipse,#3c2b21,#151116);color:#d1ac71;line-height:1;position:relative}
.pipe-empty{font-size:12px;color:#aa9683;background:repeating-linear-gradient(135deg,#171419,#171419 9px,#211c22 9px,#211c22 18px)}.pipe-piece{overflow:hidden;border-radius:0}
.pipe-piece.rotation-0 .pipe-glyph{transform:rotate(0deg)}.pipe-piece.rotation-1 .pipe-glyph{transform:rotate(90deg)}.pipe-piece.rotation-2 .pipe-glyph{transform:rotate(180deg)}.pipe-piece.rotation-3 .pipe-glyph{transform:rotate(270deg)}
.pipe-coordinate{font:10px Georgia,serif;position:absolute;left:5px;top:5px;color:#c9b795;z-index:2}.pipe-glyph{display:block;width:100%;height:100%;transition:transform .12s ease-out;transform-origin:50% 50%;transform-box:view-box;pointer-events:none}.pipe-shadow{stroke:#08070a;stroke-width:24}.pipe-metal{stroke:#ac7848;stroke-width:16}.pipe-core{stroke:#ddb57c;stroke-width:5}.flowing .pipe-metal{stroke:#c3a866}.flowing .pipe-core{stroke:#b9eeed;stroke-width:6;filter:drop-shadow(0 0 3px #69d4d0)}.pipe-terminal-mark{fill:#171318;stroke:#d2b77f;stroke-width:3}.flowing .pipe-terminal-mark{fill:#336365}.pipe-terminal strong{position:absolute;top:7px;left:7px;font-size:13px;color:#edd9b7}.pipe-terminal-status{position:absolute;bottom:7px;left:7px;font-size:10px;color:#cfb994}.pipe-connected{position:absolute;right:4px;bottom:5px;color:#b9eeed;font-size:10px;padding:2px 3px;background:#132328e8}.pipe-connected[hidden]{display:none}.pipe-piece:focus-visible{outline:3px solid #f0d49e;outline-offset:-4px;z-index:2}.pipe-piece:hover{background:#463127}.pipe-legend{display:flex;justify-content:space-between;gap:12px;font-size:12px;color:#c6b5a0}.pipe-legend span:first-child{color:#b9eeed}.pipe-explanation,.pipe-keyboard,.pipe-hint{font-size:12px;color:#c6b5a0;line-height:1.9}.pipe-keyboard{color:#aa9d8e}.pipe-actions{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}.pipe-actions .secondary-button{font-size:12px;letter-spacing:0;padding:10px 5px}.pipe-hint:empty{display:none}
.rune-board{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;margin:20px auto;max-width:440px}
.rune-key{aspect-ratio:1;min-height:56px;border:1px solid #ad8e6570;background:#201a22;display:grid;place-items:center;color:#c1a982;font-size:38px;transition:background .08s,box-shadow .08s}
.rune-key.illuminated{background:#a65360;box-shadow:0 0 30px #cf758999;color:#fff;border-color:#ffc9d4}
.memory-board{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;margin:14px auto;max-width:440px}
.memory-card{min-height:75px;aspect-ratio:4/5;border:1px solid #9f8c6744;background:linear-gradient(150deg,#31222d,#100e13);font:33px Georgia,serif;color:#86705f;display:grid;place-items:center}
.memory-card.turned{color:#f7dab0;border-color:#c49d6d;background:#46313f}
.memory-card.memory-note{padding:6px;place-items:center}
.memory-text{font-size:13px;line-height:1.55;color:#f7dab0;text-align:center}
.stage-picks{display:grid;gap:10px;margin:6px 0 14px}
.stage-switch{margin-top:10px}
.stage-hints{margin-top:16px;border-top:1px solid #9f8c6733;padding-top:10px}
.stage-hints summary{cursor:pointer;color:#d8be8f;font-size:13px;letter-spacing:.4px;min-height:44px;display:flex;align-items:center}
.stage-hints .hint-step{margin:8px 0}
.reflection-board{grid-template-columns:repeat(4,minmax(0,1fr));max-width:440px}
.reflection-cell{min-height:66px;aspect-ratio:1;background:#140e18;color:#796578;font-size:29px;border:1px solid #72506877}
.reflection-cell.glow{background:radial-gradient(ellipse,#75465d,#2c2131 80%);color:#ffd0d4;text-shadow:0 0 14px #eaa4c5}
.reflection-cell.fixed{border-color:#d9b67b88;background-color:#2c2123;opacity:1;cursor:default}
.reflection-cell:disabled{opacity:1}
#modal .challenge .secondary-button,#modal .challenge .primary-button{min-height:46px;margin-top:7px}
.ending-art{background-size:cover;background-position:center 37%;background-repeat:no-repeat}
.hotspot{touch-action:manipulation}
.hotspot:active{background:#754950;box-shadow:0 0 0 10px #c3ac8033}
@media (max-width:640px){
 .challenge-help{font-size:14px}
 .tile-board,.pipes-board,.reflection-board{width:min(100%,315px)}
 .pipe-terminal strong{font-size:12px}.pipe-actions{gap:6px}.pipe-actions .secondary-button{font-size:11px}
 .rune-key{min-height:56px;font-size:29px}
 /* Four columns leave a phone card ~60px wide: the memory text and object label clip or overlap. Two columns give
    each card room for its object and its line of testimony. */
 .memory-board{grid-template-columns:repeat(2,minmax(0,1fr));max-width:320px}
 .memory-card{aspect-ratio:1/1;min-height:0;font-size:26px}
 .memory-text{font-size:13px;line-height:1.5}
 .reflection-cell{min-height:55px}
 .ending-art{background-position:center 30%}
}
@media(prefers-reduced-motion:reduce){
 .pipe-glyph,.picture-tile,.rune-key{transition:none}
}
/* Preserve WCAG contrast in the game footer on dark backgrounds. */
footer>span:nth-child(2){color:#b9ada2}

/* Hotspots must win hit testing over the scene image at all viewport sizes. */
.scene>img{position:absolute;inset:0;z-index:0;pointer-events:none}
.scene-shade{z-index:1}
.scene-caption{z-index:2}
#hotspots{position:absolute;inset:0;z-index:50;pointer-events:auto}
#hotspots .hotspot{pointer-events:auto;z-index:51}
/* Black Bell Archive: torn birth record (typeset SVG, see ledger.js) */
.ledger{display:block;width:100%;height:100%}
.ledger-tile{padding:0;background:#d6c39b;overflow:hidden;filter:none}
.ledger-tile.placed{border-color:#d9bf8a99}
.ledger-tile.selected{filter:brightness(1.12)}
.ledger-paper{fill:#d8c59c}
.ledger-stain{fill:#8a6a3a;opacity:.13}
.ledger-frame{fill:none;stroke:#5b4128;stroke-width:2}
.ledger-frame.thin{stroke-width:.8;opacity:.7}
.ledger-rule{stroke:#5b4128;stroke-width:.8;opacity:.6}
.ledger text{font-family:'Scroll Kai','LL Serif TC','Noto Serif TC',serif;fill:#2e2016}
.ledger-title{font-size:23px;font-weight:700;letter-spacing:3px}
.ledger-small{font-size:12px;letter-spacing:1px}
.ledger-line{font-size:17px;letter-spacing:2px}
.ledger .ledger-number{font-size:34px;font-weight:700;fill:#7a1f28;letter-spacing:2px}
.ledger-mark{font-size:11px;opacity:.75}
.ledger-blot{fill:#140d0b;opacity:.88}
.ledger-seal{fill:#7a1f28}
.ledger .ledger-seal-mark{fill:#e9c9a6;font-size:20px}
.ledger-figure{width:min(100%,300px);margin:4px auto 14px;border:1px solid #b59c6c88;box-shadow:0 12px 38px #0007}
.rune-carving{margin:4px 0 12px;padding:8px 12px;border:1px dashed #b59c6c88;color:#e7d6b3;text-align:center;letter-spacing:1px}
.memory-fragments{margin:6px 0 0;padding-left:20px;color:#e7d6b3;line-height:1.7}

/* Chapter puzzles added in M6: masked guests and the glass-heart ring */
.mask-clues{margin:0 0 16px;padding-left:20px;color:#c6b5a0;font-size:13px;line-height:1.9}
.mask-board{display:grid;gap:8px;margin:0 0 14px}
.mask-row{display:grid;grid-template-columns:28px 64px 1fr;align-items:center;gap:10px;min-height:44px}
.mask-slot{font:12px Georgia,serif;color:#a99876;text-align:center}.mask-name{color:#d8be8f;font-size:14px}
.mask-row select{min-height:44px;width:100%;background:#201a22;color:#e8ddcc;border:1px solid #ad8e6570;padding:0 10px;font:inherit}

/* Mirror light path (second stage of the ballroom evidence) */
.light-board{display:grid;grid-template-columns:repeat(6,1fr);gap:3px;width:min(100%,360px);margin:12px auto 10px;padding:6px;background:#070709;border:1px solid #b49a6655}
.light-cell{aspect-ratio:1;min-height:44px;display:grid;place-items:center;background:#15111a;border:1px solid #2b2430;color:#6c5d49;font-size:20px}
.light-cell.beam{background:#2a2430;border-color:#6d7f96;color:#c9dcef;box-shadow:inset 0 0 14px #9fb6c855}
.light-mirror{background:#201a22;border-color:#ad8e6570;color:#d8be8f;font-size:28px;font-family:Georgia,serif}
.light-mirror.beam{background:#33404f;border-color:#9fb6c8;color:#fff}
.light-door{border-color:#a65360;color:#a65360}.light-door.open{background:#a65360;color:#fff;box-shadow:0 0 18px #cf758999}

/* Character portraits: painted half-body figures fade into the dialog */
.modal-portrait{display:block;margin:0 auto 14px;width:min(100%,240px);height:auto;aspect-ratio:320/468;object-fit:cover;object-position:top;border:1px solid #ad8e6540;-webkit-mask-image:linear-gradient(#000 72%,transparent);mask-image:linear-gradient(#000 72%,transparent)}

/* Second-stage mechanisms: watch gears, bed names, coffin rubbing, rabbit-ear stitches, mirror corridor */
.watch-board{display:flex;justify-content:center;margin:16px auto 12px;padding:16px 24px 10px;width:fit-content;max-width:100%;border-radius:56px;border:2px solid #b99a62;background:radial-gradient(ellipse at 50% 20%,#2e2418,#130e0b 72%);box-shadow:inset 0 0 28px #000c,0 0 0 4px #17110c,0 0 0 5px #b99a6266,0 14px 36px #0008}
.watch-gear{width:92px;min-height:44px;margin:0 -7.35px;padding:0;border:0;background:none;color:#e8d3a2;display:flex;flex-direction:column;align-items:center;gap:3px;position:relative;font-family:Georgia,serif;cursor:pointer}
.watch-gear:focus-visible{outline:2px solid #f0dca8;outline-offset:2px}
.watch-gear:nth-child(2){z-index:1}
.gear-spin{flex:none;display:block;width:92px;height:92px;transition:transform .42s cubic-bezier(.3,1.45,.5,1)}
.watch-name{font-size:12px;letter-spacing:2px;color:#f0dca8;pointer-events:none}
.rub-board{display:grid;grid-template-columns:repeat(4,1fr);gap:4px;width:min(100%,340px);margin:12px auto}
.rub-cell{aspect-ratio:1;min-height:44px;background:#0d0b0e;border:1px solid #2b2430;color:#d8be8f;font:22px Georgia,'Noto Serif TC',serif;touch-action:none}
.rub-cell.clear{background:#2a2430;border-color:#ad8e6580}
.seal-choices{display:grid;grid-template-columns:repeat(4,1fr);gap:6px;margin:8px 0 12px}
.seal-choice{min-height:44px;background:#201a22;color:#e8ddcc;border:1px solid #ad8e6570;font:20px Georgia,'Noto Serif TC',serif}
.stitch-pair{display:flex;flex-wrap:wrap;justify-content:center;gap:14px;margin:12px 0}
.stitch-caption{margin:0 0 6px;font-size:12px;color:#a99876;text-align:center}
.stitch-board{display:grid;grid-template-columns:repeat(4,44px);gap:3px;padding:5px;background:#070709;border:1px solid #b49a6655}
.stitch-cell{width:44px;height:44px;display:grid;place-items:center;background:#15111a;border:1px solid #2b2430;color:#d8be8f;font:15px Georgia,serif}
.stitch-cell.on{background:#4a2630;border-color:#a65360;color:#fff}
.maze-board{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:3px;width:min(100%,360px);margin:12px auto 8px;padding:6px;background:#070709;border:1px solid #b49a6655}
.maze-cell{aspect-ratio:1;min-height:0;display:grid;place-items:center;background:#15111a;border:1px solid #2b2430;color:#6c5d49}
.maze-cell.wall{background:#3b4656;border-color:#9fb6c8;opacity:.8}
.maze-cell.gate{background:#2a1e2c;border-color:#c49d6d;color:#e2c48e;font-size:18px}
.maze-cell.exit{border-color:#a65360;color:#cf7589;font-size:20px}
.maze-cell.here{background:#33404f;border-color:#9fb6c8;color:#fff;font-size:22px}
.maze-pad{display:grid;grid-template-columns:repeat(3,52px);grid-template-areas:'. u .' 'l d r';gap:6px;justify-content:center;margin:6px 0 10px}
.maze-key{min-width:52px;min-height:52px;background:#201a22;color:#d8be8f;border:1px solid #ad8e6570;font-size:18px}
.maze-U{grid-area:u}.maze-L{grid-area:l}.maze-D{grid-area:d}.maze-R{grid-area:r}
@media (prefers-reduced-motion:reduce){.gear-spin,.gear-ruby{transition:none}}

/* Brass finish for every mechanism and dialog control (concept boards: gilded, riveted, hand-made).
   One token set, loaded after challenges.css so it restyles the puzzle parts without touching their markup.
   The brass UI itself uses gradients and box-shadow only, nothing that needs 'unsafe-inline'; the puzzle boards add painted images (see puzzles/materials.js). */
#modal{
 --brass-hi:#f0dca8;--brass:#c9ab6a;--brass-mid:#9a7d48;--brass-lo:#5c4627;--brass-ink:#17110c;
 --ruby:#b8323f;--ruby-hi:#ff7385;
 --bevel:inset 0 1px 0 #f0dca83d,inset 0 -2px 0 #0009,0 2px 0 #000a;
}

/* Boards sit in a riveted brass plate. */
#modal :is(.tile-board,.reflection-board,.light-board,.stitch-board,.maze-board,.rub-board,.rune-board,.memory-board){
 background:
  radial-gradient(circle,#f3e1ae 0 1.5px,#8a6d3a 2px,transparent 3px) 4px 4px/9px 9px no-repeat,
  radial-gradient(circle,#f3e1ae 0 1.5px,#8a6d3a 2px,transparent 3px) calc(100% - 4px) 4px/9px 9px no-repeat,
  radial-gradient(circle,#f3e1ae 0 1.5px,#8a6d3a 2px,transparent 3px) 4px calc(100% - 4px)/9px 9px no-repeat,
  radial-gradient(circle,#f3e1ae 0 1.5px,#8a6d3a 2px,transparent 3px) calc(100% - 4px) calc(100% - 4px)/9px 9px no-repeat,
  radial-gradient(ellipse at 50% 0,#2b2117,#0f0a08 78%);
 border:2px solid var(--brass);border-radius:4px;
 box-shadow:inset 0 0 0 2px #0b0806,inset 0 0 0 3px #c9ab6a4d,inset 0 0 26px #000c,0 0 0 3px #17110c,0 0 0 4px #c9ab6a40,0 14px 36px #000a;
}
#modal :is(.rune-board,.memory-board){padding:14px;box-sizing:border-box}
#modal .pipes-board{border:2px solid var(--brass);border-radius:4px;box-shadow:inset 0 0 0 2px #0b0806,0 0 0 3px #17110c,0 0 0 4px #c9ab6a40,0 14px 36px #000a}
#modal .ledger-figure{border:2px solid var(--brass);border-radius:3px;box-shadow:0 0 0 3px #17110c,0 0 0 4px #c9ab6a40,0 14px 36px #000a}

/* Raised keys: rune keys, seal choices and the maze pad. */
#modal :is(.rune-key,.seal-choice,.maze-key){
 background:linear-gradient(#41331f,#1c150d);border:1px solid var(--brass-mid);border-radius:4px;
 color:var(--brass-hi);text-shadow:0 1px 0 #000a;box-shadow:var(--bevel);
 transition:transform .06s,box-shadow .06s,background .12s;
}
#modal :is(.rune-key,.seal-choice,.maze-key):active{transform:translateY(1px);box-shadow:inset 0 2px 5px #000b}
#modal :is(.rune-key,.seal-choice,.maze-key):focus-visible{outline:2px solid var(--brass-hi);outline-offset:2px}
/* SVG 可點元素：滑鼠點擊後不顯示瀏覽器預設的淺藍焦點框（會蓋在齒輪、棋子等圖形上）；鍵盤焦點仍由各元件的 :focus-visible 樣式呈現 */
#modal svg [tabindex]:focus:not(:focus-visible){outline:none}
#modal svg [role=button]{-webkit-tap-highlight-color:transparent}
#modal .rune-key.illuminated{
 background:radial-gradient(circle at 50% 32%,#ff9aa7,var(--ruby) 58%,#5a1220);color:#fff;border-color:var(--brass-hi);
 box-shadow:0 0 26px #ff738599,inset 0 1px 0 #fff6,inset 0 -3px 6px #3a0a12;text-shadow:0 0 8px #fff8;
}

/* Glass-heart circle: three painted layers on one ring. ring.webp is the base dial, seven painted medallions sit at their
   own --a (clockwise from the top), and a brass hand pivots at the hub. Each medallion has an unlit and a lit painting;
   lighting cross-fades between them with opacity, so nothing moves and no filter is used (MEDIA_ASSETS). */
#modal .heart-ring{
 position:relative;box-sizing:border-box;width:min(100%,330px);aspect-ratio:1;margin:12px auto 8px;padding:0;border:0;border-radius:50%;
 background:url(assets/puzzles/runeheart/ring.webp) center/100% 100% no-repeat;
 box-shadow:0 14px 36px #000a;
}
/* The hub is the gem in the base dial, measured at 51.9% across and 50.1% down the square. Every rune sits 34.5% out. */
#modal .heart-node{
 position:absolute;z-index:2;isolation:isolate;box-sizing:border-box;
 left:calc(51.9% + 34.5% * sin(var(--a)));top:calc(50.1% - 34.5% * cos(var(--a)));translate:-50% -50%;
 width:18%;aspect-ratio:1;margin:0;padding:0;border:0;border-radius:50%;
 background:var(--sym) center/118% 118% no-repeat;
 box-shadow:inset 0 0 0 999px rgba(16,9,5,.3),0 0 0 1px #2a1a08,0 0 0 3px #0000,0 0 0 #0000,0 3px 6px #000b;
 color:transparent;font-size:0;
 transition:transform .14s ease-out,box-shadow .5s ease;
}
#modal .heart-node.n0{--a:0deg;--sym:url(assets/puzzles/runeheart/sym-01.webp);--lit:url(assets/puzzles/runeheart/sym-01-lit.webp)}
#modal .heart-node.n1{--a:51.43deg;--sym:url(assets/puzzles/runeheart/sym-02.webp);--lit:url(assets/puzzles/runeheart/sym-02-lit.webp)}
#modal .heart-node.n2{--a:102.86deg;--sym:url(assets/puzzles/runeheart/sym-03.webp);--lit:url(assets/puzzles/runeheart/sym-03-lit.webp)}
#modal .heart-node.n3{--a:154.29deg;--sym:url(assets/puzzles/runeheart/sym-04.webp);--lit:url(assets/puzzles/runeheart/sym-04-lit.webp)}
#modal .heart-node.n4{--a:205.71deg;--sym:url(assets/puzzles/runeheart/sym-05.webp);--lit:url(assets/puzzles/runeheart/sym-05-lit.webp)}
#modal .heart-node.n5{--a:257.14deg;--sym:url(assets/puzzles/runeheart/sym-06.webp);--lit:url(assets/puzzles/runeheart/sym-06-lit.webp)}
#modal .heart-node.n6{--a:308.57deg;--sym:url(assets/puzzles/runeheart/sym-07.webp);--lit:url(assets/puzzles/runeheart/sym-07-lit.webp)}
/* The lit painting: ruby enamel, gold glyph. It sits over the unlit one and fades in. */
#modal .heart-node::before{
 content:'';position:absolute;inset:0;border-radius:50%;z-index:-2;
 background:var(--lit) center/118% 118% no-repeat;opacity:0;transition:opacity .5s ease;
}
/* A gold ring ripples out once as the rune catches. */
#modal .heart-node::after{
 content:'';position:absolute;inset:4%;border-radius:50%;z-index:-1;border:2px solid #ffe2a0;opacity:0;pointer-events:none;
}
#modal .heart-node.lit::before{opacity:1}
#modal .heart-node.lit::after{animation:rune-ripple .7s ease-out}
@keyframes rune-ripple{from{opacity:.95;transform:scale(.9)}to{opacity:0;transform:scale(1.5)}}
/* Lit: the dim overlay clears, a gold rim and a ruby halo appear. The shadow list keeps the same length so it interpolates. */
#modal .heart-node.lit{box-shadow:inset 0 0 0 999px rgba(16,9,5,0),0 0 0 1px #ffe2a0,0 0 0 3px #c8394a99,0 0 24px 6px #ff738599,0 3px 6px #000b}
#modal .heart-node:active{transform:scale(.94)}
#modal .heart-node:focus-visible{outline:2px solid var(--brass-hi);outline-offset:3px}
/* The hand: a painted pointer that pivots at the hub and points at the next rune to touch. The angle is set on the ring as --turn. */
#modal .heart-hand{
 position:absolute;z-index:2;left:51.9%;top:50.1%;width:77%;aspect-ratio:1;margin:-38.5% 0 0 -38.5%;pointer-events:none;
 background:url(assets/puzzles/runeheart/hand.webp) center/100% 100% no-repeat;mix-blend-mode:screen;
 transform-origin:50% 50%;transform:rotate(var(--turn,0deg));
 transition:transform .6s cubic-bezier(.3,1.25,.5,1);
}
/* The glass heart in the hub: a count on brass, with ruby glass that grows as runes light. */
#modal .heart-core{
 position:absolute;z-index:3;left:51.9%;top:50.1%;translate:-50% -50%;width:20%;aspect-ratio:1;box-sizing:border-box;border-radius:50%;
 display:grid;place-items:center;pointer-events:none;
 background:radial-gradient(circle at 40% 34%,#3a2226,#140b0e 70%);
 box-shadow:0 0 0 2px #c9ab6a,0 0 0 3px #17110c,0 0 calc(var(--glow,0) * 28px) calc(var(--glow,0) * 2px) #ff7385cc;
 color:var(--brass-hi);font:12px Georgia,serif;letter-spacing:1px;text-shadow:0 0 12px #c9ab6a66;
 transition:box-shadow .6s ease;
}
#modal .heart-core::before{
 content:'';position:absolute;inset:0;border-radius:50%;background:radial-gradient(circle at 42% 36%,#ffb3bd,#b8323f 58%,#4a0c16);
 opacity:var(--glow,0);transition:opacity .6s ease;
}
/* A wrong press shakes the dial once. */
#modal .heart-ring.jolt{animation:heart-jolt .42s cubic-bezier(.3,.7,.4,1)}
@keyframes heart-jolt{20%{transform:translateX(-5px)}40%{transform:translateX(4px)}60%{transform:translateX(-2px)}80%{transform:translateX(1px)}to{transform:none}}
#modal .heart-hint[hidden]{display:none}
@media (prefers-reduced-motion:reduce){
 #modal .heart-hand,#modal .heart-node,#modal .heart-node::before,#modal .heart-core,#modal .heart-core::before{transition:none}
 #modal .heart-node.lit::after,#modal .heart-ring.jolt{animation:none}
}

/* Mirror light path: silver beam through brass mirrors, ruby door. */
#modal .light-cell{background:#120d09;border:1px solid #3a2c1a;color:var(--brass-mid);border-radius:2px}
#modal .light-cell.beam{background:linear-gradient(#27303c,#161c25);border-color:#c8d8ec;color:#e6f0ff;box-shadow:inset 0 0 14px #bcd0e866,0 0 8px #bcd0e833}
#modal .light-mirror{background:linear-gradient(#4a3a22,#1d150d);border-color:var(--brass);color:var(--brass-hi);box-shadow:var(--bevel)}
#modal .light-mirror.beam{background:linear-gradient(#5d6c80,#2b3644);border-color:#e6f0ff;color:#fff}
#modal .light-door{border-color:var(--ruby);color:var(--ruby-hi);background:#1a0c10}
#modal .light-door.open{background:radial-gradient(circle,#ff9aa7,var(--ruby));color:#fff;border-color:var(--brass-hi);box-shadow:0 0 20px #ff738599}

/* Embroidery grid: red thread on dark cloth. */
#modal .stitch-cell{background:#120d09;border:1px solid #3a2c1a;color:var(--brass);border-radius:2px}
#modal .stitch-cell.on{background:linear-gradient(#8c2433,#5a1220);border-color:#f0b8c0;color:#fff;box-shadow:inset 0 0 8px #0006}
#modal .stitch-caption{color:var(--brass);letter-spacing:1px}

/* Mirror corridor: mirrored walls, gold traveller. */
#modal .maze-cell{background:#120d09;border:1px solid #3a2c1a;color:var(--brass-mid);border-radius:2px;opacity:1}
#modal .maze-cell.wall{background:linear-gradient(135deg,#6a7a90,#2a3442 55%,#59697e);border-color:#cfdcec;box-shadow:inset 0 0 8px #0008}
#modal .maze-cell.gate{background:linear-gradient(#4a3a22,#1d150d);border-color:var(--brass);color:var(--brass-hi)}
#modal .maze-cell.exit{background:#1a0c10;border-color:var(--ruby);color:var(--ruby-hi)}
#modal .maze-cell.here{background:radial-gradient(circle,#f6e3ab,var(--brass));border-color:var(--brass-hi);color:var(--brass-ink);box-shadow:0 0 14px #c9ab6a99}

/* Coffin rubbing: soot-black until the paper shows through. */
#modal .rub-cell{background:#0b0908;border:1px solid #2a2118;color:#0b0908;border-radius:2px}
#modal .rub-cell.clear{background:linear-gradient(#e2cfa4,#cdb787);border-color:var(--brass);color:#2e2016}

/* Reflected manuscript. */
#modal .reflection-cell{background:#120d09;border:1px solid #3a2c1a;color:var(--brass-mid);border-radius:2px}
#modal .reflection-cell.glow{background:radial-gradient(ellipse,#8a5068,#2c1c2c 82%);color:#ffe0e4;text-shadow:0 0 14px #f0a8c8}
#modal .reflection-cell.fixed{border-color:var(--brass);background-color:#241a14}

/* Memory cards: engraved brass backs, wine-dark faces. */
#modal .memory-card{
 background:linear-gradient(155deg,#3d2f1c,#130e0a);border:2px solid var(--brass-mid);border-radius:4px;color:var(--brass);
 box-shadow:inset 0 0 0 3px #0b0806,inset 0 0 0 4px #c9ab6a40,var(--bevel);text-shadow:0 1px 0 #000a;
}
#modal .memory-card.turned{background:linear-gradient(155deg,#4e2a37,#251119);border-color:var(--brass-hi);color:#f7dab0}

/* Seven names / masked guests: engraved plates with real select controls. */
#modal .mask-row{padding:2px 0}
#modal .mask-slot{width:28px;height:28px;line-height:26px;border:1px solid var(--brass-mid);border-radius:50%;background:radial-gradient(circle at 35% 28%,#4a3a22,#1a130b);color:var(--brass-hi);box-shadow:var(--bevel)}
#modal .mask-row select{
 appearance:none;-webkit-appearance:none;min-height:44px;padding:0 38px 0 12px;border:1px solid var(--brass-mid);border-radius:4px;
 background:
  linear-gradient(45deg,transparent 50%,var(--brass) 50%) calc(100% - 20px) 50%/7px 7px no-repeat,
  linear-gradient(135deg,var(--brass) 50%,transparent 50%) calc(100% - 14px) 50%/7px 7px no-repeat,
  linear-gradient(#2a2016,#140e0a);
 color:var(--brass-hi);box-shadow:var(--bevel);cursor:pointer;
}
#modal .mask-row select:focus-visible{outline:2px solid var(--brass-hi);outline-offset:2px}
#modal .mask-row select option{background:#17110c;color:#f0dca8}
#modal .mask-clues{counter-reset:clue;list-style:none;padding:12px 14px;border:1px solid #c9ab6a40;border-radius:4px;background:#0e0a0788}
#modal .mask-clues li{counter-increment:clue;position:relative;padding-left:26px;margin:2px 0}
#modal .mask-clues li::before{content:counter(clue);position:absolute;left:0;top:.45em;width:18px;height:18px;line-height:17px;text-align:center;font:11px Georgia,serif;color:var(--brass-ink);background:var(--brass);border-radius:50%}
#modal .rune-carving{border:1px solid var(--brass-mid);border-radius:4px;background:linear-gradient(#1c150d,#110c08);box-shadow:inset 0 0 0 3px #0b0806,inset 0 0 0 4px #c9ab6a33;color:var(--brass-hi);letter-spacing:3px}

/* Code input: engraved dial. */
#modal .code-input{background:linear-gradient(#0b0806,#17110c);border:2px solid var(--brass-mid);border-radius:4px;color:var(--brass-hi);box-shadow:inset 0 3px 10px #000c,0 1px 0 #f0dca826;text-shadow:0 0 10px #c9ab6a66}
#modal .code-input:focus{border-color:var(--brass-hi);outline:none;box-shadow:inset 0 3px 10px #000c,0 0 0 3px #c9ab6a40}

/* Buttons inside dialogs. */
#modal .primary-button{background:linear-gradient(var(--btn-red-top),var(--btn-red-bottom));border:1px solid var(--btn-gold-line);box-shadow:inset 0 1px 0 #ffd9dd40,0 4px 14px #74202c66;text-shadow:0 1px 0 #0006}
#modal .primary-button:hover:not(:disabled){background:linear-gradient(var(--btn-red-hover-top),var(--btn-red-hover-bottom));filter:brightness(1.08)}
#modal .primary-button:disabled{background:linear-gradient(#3a2c1a,#241b10);border-color:var(--brass-lo);box-shadow:none;text-shadow:none}
#modal .secondary-button{background:linear-gradient(#2a2016,#16100b);border:1px solid var(--brass-mid);color:var(--brass-hi);box-shadow:inset 0 1px 0 #f0dca826}
#modal .secondary-button:hover:not(:disabled){background:linear-gradient(#34281b,#1d150e);border-color:var(--brass)}
#modal .choice-option{background:linear-gradient(#2a2016,#16100b);border:1px solid var(--brass-mid);color:var(--brass-hi);box-shadow:var(--bevel)}
#modal .choice-option:hover:not(:disabled){border-color:var(--brass-hi);background:linear-gradient(#3a2d1d,#1d150e)}
#modal .choice-option small{display:block;margin-top:2px;color:#cdbb97;letter-spacing:.5px}
#modal .stage-pick{text-align:left;font-size:16px;letter-spacing:2px}
#modal .challenge-feedback{color:var(--brass-hi);padding-left:12px;border-left:2px solid var(--brass-mid);margin-top:6px}

/* Hint panel: a lantern drawer rather than a bare summary line. */
#modal .stage-hints{margin-top:18px;padding:0 14px 12px;border:1px solid #c9ab6a40;border-radius:4px;background:linear-gradient(#17110c99,#0e0a0799)}
#modal .stage-hints summary{color:var(--brass-hi);letter-spacing:2px;list-style:none}
#modal .stage-hints summary::-webkit-details-marker{display:none}
#modal .stage-hints summary::before{content:'✧';margin-right:8px;color:var(--brass)}
#modal .stage-hints summary::after{content:'';margin-left:auto;width:7px;height:7px;border:solid var(--brass);border-width:0 1.5px 1.5px 0;transform:rotate(45deg) translateY(-2px);transition:transform .15s}
#modal .stage-hints[open] summary::after{transform:rotate(225deg) translateY(-2px)}
#modal .stage-hints .hint-step{padding-left:12px;border-left:2px solid var(--brass-mid);color:#d6c8b0;line-height:1.85}
#modal .stage-hints[open]{background:linear-gradient(#1d150e,#110c08)}
#modal .stage-switch{color:var(--brass-hi);letter-spacing:1px}

/* Close-up picture at the head of each mechanism (see puzzles/index.js) and the scene zoom on clue dialogs. */
#modal .stage-art{display:block;width:calc(100% + 64px);max-width:none;height:176px;margin:-24px -32px 16px;object-fit:cover;object-position:50% 45%;
 -webkit-mask-image:linear-gradient(#000 58%,transparent);mask-image:linear-gradient(#000 58%,transparent);border-bottom:0}
#modal .spot-zoom{position:relative;width:100%;aspect-ratio:16/6.5;margin:0 0 18px;border:2px solid var(--brass);border-radius:4px;background-repeat:no-repeat;background-color:#0e0a07;
 box-shadow:inset 0 0 0 2px #0b0806,inset 0 0 36px #000c,0 0 0 3px #17110c,0 0 0 4px #c9ab6a40,0 12px 30px #000a;overflow:hidden}
#modal .spot-zoom::after{content:'';position:absolute;inset:0;background:radial-gradient(ellipse at 50% 50%,transparent 45%,#0b0806cc);pointer-events:none}
#modal .spot-zoom .ui-icon{position:absolute;left:10px;bottom:10px;z-index:1;width:36px;height:36px;padding:7px;box-sizing:border-box;border:1px solid var(--brass);border-radius:50%;background:#120d09e6;color:var(--brass-hi)}
@media (max-width:560px){
 #modal .stage-art{width:calc(100% + 44px);margin:-20px -22px 14px;height:128px}
}
@media (prefers-reduced-motion:reduce){
 #modal :is(.rune-key,.seal-choice,.maze-key){transition:none}
 #modal .stage-hints summary::after{transition:none}
}

/* Music box: pins stand on a brass cylinder; a raised pin lifts and glows. */
#modal .musicbox-pins{align-items:flex-end;gap:16px;width:fit-content;max-width:100%;margin:18px auto 14px;padding:22px 26px 26px;border:2px solid var(--brass);border-radius:4px;
 background:linear-gradient(#0f0a08 0,#2b2117 14%,#0f0a08 100%);
 box-shadow:inset 0 0 0 2px #0b0806,inset 0 0 0 3px #c9ab6a4d,inset 0 0 24px #000c,0 0 0 3px #17110c,0 0 0 4px #c9ab6a40,0 14px 36px #000a}
#modal .music-pin{position:relative;width:52px;height:80px;border:1px solid var(--brass);border-radius:26px 26px 8px 8px;color:var(--brass-hi);
 background:linear-gradient(90deg,#4a3a22,#8a6d3a 38%,#e6cf93 52%,#8a6d3a 66%,#3a2c1a);box-shadow:var(--bevel);transition:transform .16s cubic-bezier(.3,1.5,.5,1),box-shadow .16s;text-shadow:0 1px 0 #000a}
#modal .music-pin.raised{transform:translateY(-16px);background:linear-gradient(90deg,#6e2330,#d44a5c 40%,#ff9aa7 52%,#d44a5c 66%,#5a1220);color:#fff;box-shadow:0 0 22px #ff738588,inset 0 1px 0 #fff6}
#modal .music-pin:focus-visible{outline:2px solid var(--brass-hi);outline-offset:3px}
#modal .lullaby-score{color:var(--brass-hi);text-shadow:0 0 10px #c9ab6a66}
#modal .challenge-feedback:empty{border:0;padding:0}
@media (prefers-reduced-motion:reduce){#modal .music-pin{transition:none}}

/* Two-stage evidence: the picker shows each mechanism's picture. */
#modal .stage-pick{display:flex;align-items:center;gap:14px;padding:8px 14px 8px 8px;text-align:left}
#modal .stage-thumb{flex:none;width:112px;height:64px;object-fit:cover;border:1px solid var(--brass-mid);border-radius:4px;box-shadow:0 2px 8px #000a}
#modal .stage-pick-text{display:block;min-width:0}
#modal .stage-pick:disabled .stage-thumb{filter:grayscale(.85) brightness(.55)}
#modal .stage-pick:disabled small::before{content:'✓ ';color:var(--brass)}
@media (max-width:560px){#modal .stage-thumb{width:88px;height:56px}}

/* 帳本的背面 (鏡淵): the home entry, the level list and the belfry gear train (puzzles/gears13.js) */
.abyss-entry{display:flex;align-items:center;justify-content:space-between;gap:24px;margin:0 7% 48px;padding:26px 30px;border:1px solid var(--line);background:radial-gradient(ellipse at 15% 50%,#3a1f2a55,transparent 70%),#151116}
.abyss-entry h2{font:400 22px var(--serif);letter-spacing:3px;margin:0 0 8px}
.abyss-entry p{margin:0;font-size:12px;color:#a59a8d;letter-spacing:.6px}
.abyss-entry .eyebrow{margin:0 0 10px}
.abyss-entry .abyss-progress{margin-top:8px;color:var(--gold);letter-spacing:1px}
.abyss-entry button{flex:none;border:1px solid var(--line);padding:12px 22px;color:var(--gold);letter-spacing:1px}
@media (max-width:560px){.abyss-entry{margin:0 24px 36px;padding:22px 20px;flex-direction:column;align-items:stretch}.abyss-entry button{width:100%}}
#modal .abyss-scene{margin:0 0 6px}
#modal .abyss-line{margin:0 0 10px;font:15px/1.95 var(--serif);color:#d2c6b6}
#modal .abyss-line.spoken{color:#cfc0a6}
#modal .abyss-line b{display:block;font:11px var(--sans);letter-spacing:2px;color:var(--gold);margin-bottom:1px}
#modal .abyss-levels{display:grid;gap:10px;margin:14px 0 4px}
#modal .abyss-level{display:flex;align-items:center;gap:14px;padding:8px 14px 8px 8px;text-align:left;margin:0}
#modal .abyss-reward{display:flex;align-items:center;gap:16px;margin:14px 0 4px;padding:14px 18px;border:1px solid var(--brass-mid);background:#1b140d;color:var(--brass-hi);font:16px var(--serif);letter-spacing:2px}
#modal .abyss-reward small{display:block;margin-top:2px;font:11px var(--sans);letter-spacing:1px;color:#b8a07a}
#modal .abyss-mark{flex:none;width:52px;height:52px;display:grid;place-items:center;border:2px solid var(--brass);border-radius:50%;font:26px var(--serif);color:var(--brass-hi);background:radial-gradient(circle at 35% 30%,#6e5632,#241a0f 72%);box-shadow:0 0 18px #c9ab6a40}
#modal .belfry-rules{margin:0 0 12px;padding-left:22px;font-size:13px;line-height:1.9;color:#c0b199}
#modal .belfry-status{min-height:46px;margin:0 0 10px;padding:6px 12px;border-left:2px solid var(--brass-mid);font-size:13px;line-height:1.8;color:var(--brass-hi)}
#modal .belfry-status[data-tone=ok]{border-left-color:#7fd08a;color:#bfeac5}
#modal .belfry-status[data-tone=bad]{border-left-color:#d8665f;color:#f1b3ad}
#modal .belfry-board{border:2px solid var(--brass);border-radius:4px;background:radial-gradient(ellipse at 50% 45%,#0a060a55,#0a060ab0 90%),url(assets/puzzles/belfry-board.webp) center/100% 100% no-repeat,#120b10;box-shadow:inset 0 0 0 2px #0b0806,0 0 0 3px #17110c,0 0 0 4px #c9ab6a40,0 14px 36px #000a}
#modal .belfry-svg{display:block;width:100%;height:auto;touch-action:manipulation}
#modal .belfry-gear .gear-body{fill:url(#bm-brass);stroke:url(#bm-edge-brass);stroke-width:.32;stroke-linejoin:round}
#modal .belfry-gear.layer1 .gear-body{fill:url(#bm-copper);stroke:url(#bm-edge-copper)}
#modal .belfry-gear .gear-web{fill:url(#bm-brass);stroke:none}
#modal .belfry-gear.layer1 .gear-web{fill:url(#bm-copper)}
#modal .belfry-gear .gear-rimline{fill:url(#bm-web);stroke:#2a1704;stroke-opacity:.55;stroke-width:.22}
#modal .belfry-gear .gear-hole{fill:url(#bm-hole);stroke:#e7c978;stroke-opacity:.55;stroke-width:.16}
#modal .belfry-gear.layer1 .gear-hole{stroke:#e9a27c}
#modal .belfry-gear .gear-hub{fill:url(#bm-pin);stroke:#3a2508;stroke-width:.18}
#modal .belfry-gear.layer1 .gear-hub{fill:url(#bm-pin-copper)}
#modal .belfry-gear .gear-axle{fill:#1b1005;stroke:none}
#modal .belfry-gear.bad .gear-body{stroke:#ff3b33;stroke-width:.9}
#modal .gear-shadow{fill:#000;fill-opacity:.34}
#modal .gear-roundness{fill:url(#bm-roundness)}
#modal .belfry-socket{fill:url(#bm-well);stroke:url(#bm-lip);stroke-width:.5;pointer-events:none}
#modal .belfry-socket.out{stroke:#ff5555;stroke-width:.9}
#modal .belfry-hit{fill:transparent;cursor:pointer;outline:none;-webkit-tap-highlight-color:transparent}
#modal .belfry-hit:hover{stroke:#e7c978;stroke-opacity:.5;stroke-width:.5}
#modal .belfry-hit:focus-visible{stroke:var(--brass-hi);stroke-width:.8}
#modal .belfry-out-ring{fill:none;stroke:#ff5555;stroke-width:.5;stroke-dasharray:1.2 1;pointer-events:none}
#modal .belfry-out-mark{fill:#ff3b33;pointer-events:none}
#modal .belfry-crank{stroke:#4a2f08;stroke-width:1.5;stroke-linecap:round;pointer-events:none}
#modal .belfry-crank-hi{stroke:#ffe8a0;stroke-width:.55;stroke-linecap:round;pointer-events:none}
#modal .belfry-knob{fill:url(#bm-pin);stroke:#3a2508;stroke-width:.3;pointer-events:none}
#modal .belfry-label{font-size:2.6px;fill:#e9dcc3;text-anchor:middle;pointer-events:none}
#modal .belfry-label.out{fill:#ff8f8f}
#modal .belfry-label.dim{opacity:.55}
#modal .belfry-ruler{stroke:#99ffdd;stroke-width:.25;stroke-dasharray:1 1;pointer-events:none}
#modal .belfry-dist{font-size:3.4px;font-weight:700;paint-order:stroke;stroke:#0b0710;stroke-width:.6px;fill:#99ffdd;text-anchor:middle;pointer-events:none}
#modal .belfry-row{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin:10px 0 4px}
#modal .belfry-row .secondary-button{width:auto;margin:0;padding:8px 14px}
#modal #bf-layers{display:flex;gap:8px;flex-wrap:wrap}
#modal .belfry-layer[aria-pressed=true],#modal #bf-ruler[aria-pressed=true]{background:#4a3414;border-color:var(--brass);color:var(--brass-hi)}
#modal .belfry-note{font-size:12px;color:#9fb8a6;font-variant-numeric:tabular-nums}
#modal .belfry-tray{display:flex;flex-wrap:wrap;gap:8px;margin:10px 0}
#modal .belfry-gear-button{width:76px;min-height:92px;display:flex;flex-direction:column;align-items:center;padding:4px;border:2px solid #3a2a14;border-radius:4px;background:#150d1a;color:#e9dcc3;font-size:12px}
#modal .belfry-gear-button[aria-pressed=true]{border-color:var(--brass);background:#2d1d10}
#modal .belfry-gear-button:disabled{opacity:.35}
#modal .belfry-gear-button svg{width:60px;height:60px}
#modal .belfry-gear-button:focus-visible{outline:2px solid var(--brass-hi);outline-offset:2px}
#modal .belfry-hint{display:flex;flex-wrap:wrap;align-items:center;gap:10px;margin-top:6px}
#modal .belfry-hint .secondary-button{width:auto;margin:0;padding:8px 16px}
#modal .belfry-hint-text{margin:8px 0 0;padding:8px 12px;border-left:3px solid #77eeff;background:#10202a;font-size:13px;line-height:1.85;color:#cfe9ee}
#modal .belfry-hint-text[hidden],#modal #bf-run[hidden]{display:none}
#modal #bf-run:disabled{opacity:.5}
/* the pendulum (puzzles/pendulum.js) */
#modal .pend-beam{fill:url(#bm-brass);stroke:url(#bm-edge-brass);stroke-width:1}
#modal .pend-beam-shadow{fill:#000;fill-opacity:.3}
#modal .pend-beam-shine{fill:#fff6d8;fill-opacity:.28}
#modal .pend-rivet{fill:url(#bm-pin);stroke:#3a2508;stroke-width:.5}
#modal .pend-pivot{fill:url(#bm-pin);stroke:#2a1a05;stroke-width:1}
#modal .pend-rod{stroke:#4a2f08;stroke-width:3.4;stroke-linecap:round}
#modal .pend-rod.old{stroke:#3a2e1a;stroke-width:2.8}
#modal .pend-rod-hi{stroke:#ffe8a0;stroke-width:1.1;stroke-opacity:.75;stroke-linecap:round}
#modal .pend-label{font-size:12px;fill:#d9c9a4;text-anchor:middle}
#modal .pend-scale{font-size:9px;fill:#8f8168;text-anchor:end}
#modal .pend-tick{stroke:#6b5a3a;stroke-width:1}
#modal .pend-bell{font-size:20px;fill:#ffd98a;text-anchor:middle;font-weight:700}
#modal .belfry-weight b{font-size:11px;margin-top:2px}
#modal .pend-disc-slot{display:grid;place-items:center;width:60px;height:60px}
#modal .pend-disc-slot img{display:block;filter:drop-shadow(0 2px 3px #000a)}
#modal .belfry-weight{width:96px}
/* the star wheel (puzzles/starwheel.js) */
#modal .wheel-board{max-width:420px;margin:0 auto}
#modal .wheel-ring{fill:none;stroke:url(#bm-brass);stroke-width:10}
#modal .wheel-ring-shadow{fill:none;stroke:#000;stroke-opacity:.38;stroke-width:10}
#modal .wheel-ring-lit{fill:none;stroke:#fff0b8;stroke-opacity:.55;stroke-width:1}
#modal .wheel-ring-dark{fill:none;stroke:#2a1704;stroke-opacity:.7;stroke-width:1.4}
#modal .wheel-hub{fill:url(#bm-brass);stroke:url(#bm-edge-brass);stroke-width:2}
#modal .wheel-hub-lit{fill:url(#bm-web);stroke:#2a1704;stroke-opacity:.5;stroke-width:1}
#modal .wheel-notch{stroke:#1d1308;stroke-width:4.2;stroke-linecap:round}
#modal .wheel-ruby{filter:drop-shadow(0 0 5px #ff4f6a88)}
#modal .wheel-glyph{font:600 15px var(--serif);fill:#ffe9ad;text-anchor:middle;opacity:0;transition:opacity .35s}
#modal .wheel-svg.lit .wheel-glyph{opacity:1}
body.reduce-motion #modal .wheel-glyph{transition:none}
#modal .wheel-hammer-turn{transform-origin:160px 160px;transition:transform .36s cubic-bezier(.3,1.35,.5,1)}
body.reduce-motion #modal .wheel-hammer-turn{transition:none}
#modal .wheel-hammer{stroke:#5a1f12;stroke-width:5;stroke-linecap:round}
#modal .wheel-hammer-hi{stroke:#ffb48a;stroke-width:1.4;stroke-opacity:.7;stroke-linecap:round}
#modal .wheel-hammer-head{fill:url(#bm-pin-copper);stroke:#3a1206;stroke-width:1.2}
#modal .wheel-pin{fill:url(#bm-pin);stroke:#2a1a05;stroke-width:1.2}
#modal .wheel-toll{font:700 26px var(--serif);fill:#ffe9ad;text-anchor:middle}
#modal .wheel-engraving{margin:10px 0 0;padding:8px 12px;border-left:3px solid #e0b84f;background:#1f170d;font-size:13px;line-height:1.85;color:#ecd9a8}
#modal .wheel-engraving[hidden]{display:none}
#modal .wheel-step{display:inline-flex;align-items:center;gap:8px;margin-left:auto}
#modal .wheel-step .secondary-button{width:44px;padding:0;margin:0}
/* E2 prism ballroom (puzzles/prism.js): beams add up like light, mirrors and dancers are the touch targets. */
#modal .prism-board{max-width:560px;margin:0 auto}
#modal .prism-beams{mix-blend-mode:screen}
#modal .prism-hit{cursor:pointer;outline:none}
#modal .prism-tint{mix-blend-mode:color;pointer-events:none}
#modal .prism-mask-lit,#modal .prism-halo,#modal .prism-over{opacity:0}
#modal .prism-svg.ready .prism-mask-lit,#modal .prism-svg.ready .prism-halo,#modal .prism-svg.ready .prism-over,#modal .prism-svg.ready .prism-crystal-tint{transition:opacity .35s ease}
#modal .prism-svg.ready .prism-blade{transition:transform .24s cubic-bezier(.3,1.5,.5,1)}
#modal .prism-svg.ready .prism-dancer,#modal .prism-svg.ready .prism-ghost{transition:transform .3s ease}
body.reduce-motion #modal .prism-svg .prism-mask-lit,body.reduce-motion #modal .prism-svg .prism-halo,body.reduce-motion #modal .prism-svg .prism-over,body.reduce-motion #modal .prism-svg .prism-crystal-tint,body.reduce-motion #modal .prism-svg .prism-blade,body.reduce-motion #modal .prism-svg .prism-dancer,body.reduce-motion #modal .prism-svg .prism-ghost{transition:none}
/* 焦點框畫在命中區本身：各鏡子的命中元素分別是首或末位的 circle／rect；舞者沒有命中區，改用本體圓環 */
#modal .prism-hit:focus-visible > :is(circle, rect):is(:first-child, :last-child),#modal .prism-dancer-control:focus-visible > circle:first-child{stroke:#fff;stroke-width:1}
/* 瀏覽器預設的 auto 焦點框會套在 SVG 群組的邊界框上，而該邊界框被底圖的 sprite 撐大，框線會落在錯誤位置 */
#modal .prism-dancer-control{outline:none}

/* E3 apothecary (puzzles/apothecary.js): testimony cards read through a hand mirror, one-way vessels, colour mixing. */
#modal .apo-note{font-size:12px;color:#cdbf9f}
#modal .apo-cards{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:8px;margin:8px 0}
#modal .apo-card{display:flex;flex-direction:column;gap:4px;min-height:170px;padding:8px;border:2px solid #3a2a14;border-radius:4px;background:#150d1a;color:#e9dcc3;text-align:left}
#modal .apo-card svg{width:34px;height:34px}
#modal .apo-card-line{font-size:12px;font-style:italic;color:#cdbf9f}
#modal .apo-say{font-size:13px;line-height:1.5}
#modal .apo-mirrored .apo-say{display:inline-block;transform:scaleX(-1)}
#modal .apo-card.struck{opacity:.5;border-style:dashed}
#modal .apo-acts{display:flex;gap:6px;margin-top:auto}
#modal .apo-acts .secondary-button{flex:1;min-width:44px;min-height:44px;width:auto;margin:0;padding:0 8px}
#modal .apo-acts [aria-pressed=true]{background:#5a3a14}
#modal .belfry-row [aria-pressed=true]{background:#5a3a14}
#modal .apo-board{max-width:520px;margin:0 auto}
#modal .apo-shadow{fill:#000;fill-opacity:.4}
#modal .apo-glass-back{fill:#0c1220;fill-opacity:.55}
#modal .apo-glass{fill:url(#bm-glass);stroke:#bcd4f2;stroke-opacity:.8;stroke-width:1.3}
#modal .apo-liquid{fill:url(#bm-liquid)}
#modal .apo-surface{fill:#ffb199;fill-opacity:.6}
#modal .apo-glint{fill:#fff;fill-opacity:.22}
#modal .apo-base{fill:url(#bm-brass);stroke:url(#bm-edge-brass);stroke-width:.8}
#modal .apo-tube{cursor:pointer;outline:none}
#modal .apo-tube.off{opacity:.3;cursor:default}
#modal .apo-tube:focus-visible path:first-of-type{stroke:#fff}
#modal .apo-mixer{display:grid;grid-template-columns:1fr 1fr;gap:12px;max-width:560px;margin:8px 0}
#modal .apo-swatch{position:relative;height:96px;overflow:hidden;display:flex;align-items:flex-end;justify-content:center;border:2px solid #6b5a3a;border-radius:4px;font-size:12px;color:#fff}
#modal .apo-swatch span{position:relative;z-index:1;margin-bottom:4px;padding:0 6px;border-radius:4px;background:#000a}
#modal .apo-swatch.glass::after{content:"";position:absolute;inset:0;background:rgba(40,160,90,.42)}
#modal .apo-swatch.lit{box-shadow:0 0 18px 4px #fff8}
#modal .apo-drop{display:flex;align-items:center;gap:8px;margin:6px 0}
#modal .apo-drop b{min-width:5.6em}
#modal .apo-pigment-R{color:#f06a6a}
#modal .apo-pigment-Y{color:#f0d060}
#modal .apo-pigment-B{color:#7ea0ff}
#modal .apo-drop .secondary-button{width:auto;min-width:44px;min-height:44px;margin:0;padding:0 12px}
#modal .apo-count{min-width:3em;text-align:center}

/* E4 gallery (puzzles/gallery.js): four panels on a 744x548 board scaled to the modal; one panel can fill the board, the rest wait as tiles. */
#modal .gal-caption{margin:6px 0;min-height:4.6em;font-size:13px;line-height:1.7;color:#f3e6bd}
#modal .gal-stage{position:relative;width:100%;max-width:744px;margin:6px auto;overflow:hidden;border-radius:4px;background:#0b0a0f}
#modal .gal-stage[hidden]{display:none}
#modal .gal-board{position:absolute;left:0;top:0;width:744px;height:548px;transform-origin:0 0}
#modal .gal-guide{position:absolute;left:0;top:0;width:744px;height:548px;overflow:visible;pointer-events:none;z-index:50}
#modal .gal-panel{position:absolute;box-sizing:border-box;width:352px;height:200px;border:6px solid #8a6a2a;border-radius:4px;overflow:hidden;background:#000;touch-action:none;cursor:grab;box-shadow:0 0 0 2px #3d2f12,0 6px 18px #000a;transform-origin:0 0}
#modal .gal-panel.drag{cursor:grabbing;box-shadow:0 0 0 2px #e8c46a,0 12px 28px #000c}
#modal .gal-panel:focus-visible{outline:3px solid #e8c46a;outline-offset:2px}
body:not(.reduce-motion) #modal .gal-panel{transition:left .3s,top .3s}
body:not(.reduce-motion) #modal .gal-panel.drag{transition:none}
#modal .gal-layer{position:absolute;left:0;top:0;transform-origin:0 0}
#modal .gal-layer img{position:absolute;left:0;top:0;width:100%;height:100%;max-width:none;display:block;-webkit-user-drag:none;user-select:none}
#modal .gal-ring{position:absolute;box-sizing:border-box;border:2px dashed #fff;border-radius:50%;box-shadow:0 0 0 1px #000a,inset 0 0 0 1px #000a;pointer-events:none}
#modal .gal-ring.on{border-style:solid;border-color:#e8c46a}
#modal .gal-notch{position:absolute;width:30px;height:20px;pointer-events:none;background:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 20'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='%23fff3c0'/%3E%3Cstop offset='.55' stop-color='%23e8c46a'/%3E%3Cstop offset='1' stop-color='%23a8761f'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect x='6' y='8' width='16' height='4' rx='2' fill='url(%23g)' stroke='%233a2406' stroke-width='.8'/%3E%3Ccircle cx='5' cy='10' r='4.6' fill='url(%23g)' stroke='%233a2406' stroke-width='.8'/%3E%3Ccircle cx='5' cy='10' r='1.7' fill='%233a2406'/%3E%3Ccircle cx='5' cy='10' r='.6' fill='%23ffe9a0'/%3E%3Ccircle cx='22.5' cy='10' r='2.6' fill='url(%23g)' stroke='%233a2406' stroke-width='.8'/%3E%3Cpath d='M25.4 5.2L29.4 10l-4 4.8z' fill='%23ffd978' stroke='%233a2406' stroke-width='.7' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat;filter:drop-shadow(0 0 3px #000c)}
#modal .gal-notch[data-side="L"]{transform:scaleX(-1)}
#modal .gal-tag{position:absolute;left:6px;top:4px;padding:1px 8px;border-radius:4px;background:#000b;font-size:12px;color:#fff}
#modal .gal-tools{display:flex;flex-direction:column;gap:4px;margin:6px 0}
#modal .gal-tools[hidden]{display:none}
#modal .gal-tools-row{display:flex;flex-wrap:wrap;align-items:center;gap:6px}
#modal .gal-tools-row b{min-width:2.4em;font-size:13px}
#modal .gal-tools .secondary-button{width:auto;min-width:44px;min-height:44px;margin:0;padding:0 12px}
#modal .gal-tools [aria-pressed=true]{background:#5a3a14}
#modal .gal-place{margin:6px 0;font-size:13px}
#modal .gal-place[hidden]{display:none}
#modal .gal-place summary{min-height:44px;display:flex;align-items:center;cursor:pointer}
#modal .gal-place-body{display:flex;flex-wrap:wrap;align-items:flex-end;gap:8px}
#modal .gal-place-body label{display:flex;flex-direction:column;gap:2px;font-size:12px;color:#cdbf9f}
#modal .gal-place-body select{min-height:44px;max-width:100%;font:inherit;color:#e9dcc3;background:#1d1a24;border:1px solid #3a3446;border-radius:4px}
#modal .gal-place-body .secondary-button{width:auto;min-height:44px;margin:0;padding:0 16px}
#modal .gal-order[hidden]{display:none}
#modal .gal-threads,#modal .gal-order-note{font-size:13px;line-height:1.7;color:#cdbf9f}
#modal .gal-slots,#modal .gal-cards{display:flex;gap:6px;margin:8px 0}
#modal .gal-slot,#modal .gal-card{position:relative;flex:1 1 20%;min-width:56px;aspect-ratio:16/9;padding:0;overflow:hidden;display:flex;align-items:center;justify-content:center;border-radius:4px;background:#000;color:#cdbf9f;cursor:pointer}
#modal .gal-slot{border:2px dashed #5a4f68}
#modal .gal-slot:not(.empty),#modal .gal-card{border:2px solid #8a6a2a}
#modal .gal-slot.empty{cursor:default}
#modal .gal-slot img,#modal .gal-card img{position:absolute;inset:0;width:100%;height:100%;max-width:none;object-fit:cover}
#modal .gal-slot span,#modal .gal-card span{position:relative;padding:1px 6px;border-radius:4px;background:#000b;font-size:12px;white-space:nowrap;color:#fff}
#modal .gal-card.used{opacity:.35}
#modal .gal-line{display:block;width:100%;max-width:540px;margin:12px auto}
/* E5 七重魔鏡匣 (puzzles/box.js): the six faces of the box */
#modal .box-body{margin:6px 0 4px}
#modal .box-row{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:8px;margin:10px 0}
#modal .box-row.wrap{gap:8px}
#modal .box-row .secondary-button,#modal .box-row .primary-button{flex:none;width:auto;min-width:44px;min-height:44px;margin:0;padding:0 16px}
#modal .box-line{margin:10px 0;font-size:13px;line-height:2;color:#cdbf9f}
#modal .box-dim{color:#7d7288}
#modal .box-readout{flex:1 1 0;min-width:0;text-align:center;font-size:14px;color:var(--brass-hi)}
#modal .box-chip{display:inline-flex;align-items:center;gap:4px;margin:0 3px;padding:1px 9px;border:1px solid #6b5a3a;border-radius:4px;background:#120b17;font-size:13px;color:#e9dcc3}
#modal .box-chip b{font-weight:400}
#modal .box-dial{display:block;width:min(100%,300px);height:auto;margin:6px auto;touch-action:manipulation}
#modal .box-dial-rim{fill:url(#bm-brass);stroke:url(#bm-edge-brass);stroke-width:2}
#modal .box-dial-shadow{fill:#000;fill-opacity:.42}
#modal .box-dial-shine{fill:none;stroke:#fff0b8;stroke-opacity:.5;stroke-width:1}
#modal .box-dial-face{fill:#0b0710;stroke:#2a1704;stroke-width:1.4}
#modal .box-dial-ring{fill:none;stroke:#e7c978;stroke-opacity:.45;stroke-width:.8}
#modal .box-notch{cursor:pointer}
#modal .box-notch .hit{fill:url(#bm-web);stroke:url(#bm-lip);stroke-width:1.2}
#modal .box-notch text{font-size:9px;fill:#e9dcc3;pointer-events:none}
#modal .box-notch.on .hit{fill:url(#bm-pin);stroke:#fff0b8;stroke-width:2}
#modal .box-notch.on text{fill:#2a1608;font-weight:700}
#modal .box-notch:focus-visible .hit{stroke:#fff;stroke-width:2.5}
#modal .box-pointer{stroke:#5a1f12;stroke-width:4;stroke-linecap:round}
#modal .box-pointer-hi{stroke:#ffb48a;stroke-width:1.2;stroke-opacity:.75;stroke-linecap:round}
#modal .box-hub{fill:url(#bm-pin);stroke:#2a1a05;stroke-width:1}
#modal .box-glass{min-height:56px;display:flex;flex-wrap:wrap;align-items:center;gap:6px;padding:10px 12px;border:1px solid #3a2a14;border-radius:4px;background:linear-gradient(145deg,#0b0710,#171018)}
#modal .box-glass.lit{border-color:var(--brass);background:radial-gradient(ellipse at 50% 0,#2a1a2e,#0b0710 80%)}
#modal .box-glass-title{font-size:12px;color:#b8a07a}
#modal .box-color{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-width:64px;min-height:48px;padding:0 12px;border:2px solid currentColor;border-radius:4px;background:#120b17;font:15px var(--serif);cursor:pointer}
#modal .box-color b{font-weight:400;font-size:18px}
#modal .box-color:hover{background:#241522}
#modal .c-R{color:#ff7a7a}#modal .c-G{color:#6bff95}#modal .c-B{color:#7fa8ff}#modal .c-Y{color:#ffd966}#modal .c-P{color:#d59bff}
#modal .box-apples{display:grid;grid-template-columns:repeat(auto-fill,minmax(88px,1fr));gap:8px;margin:10px 0}
#modal .box-apple{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;min-height:64px;padding:6px;border:2px solid #8a6a2a;border-radius:50% 50% 46% 46%/58% 58% 42% 42%;background:radial-gradient(circle at 38% 30%,#6a2a30,#1b0c10 75%);color:#f2e6cf;cursor:pointer}
#modal .box-apple b{font:12px var(--sans);color:#d8be8f}
#modal .box-apple span{font:15px var(--serif);letter-spacing:1px}
#modal .box-apple.on{border-color:#fff;box-shadow:0 0 14px #e0b84f88}
#modal .box-apple.tried{opacity:.4}
#modal .box-holes{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin:10px 0}
#modal .box-hole{position:relative;aspect-ratio:16/9;min-height:56px;padding:0;overflow:hidden;display:flex;align-items:flex-end;justify-content:center;border:2px solid #8a6a2a;border-radius:4px;background:#000;cursor:pointer}
#modal .box-hole img{position:absolute;inset:0;width:100%;height:100%;max-width:none;object-fit:cover}
#modal .box-hole span{position:relative;margin-bottom:6px;padding:1px 10px;border-radius:4px;background:#000b;font-size:13px;color:#fff}
#modal .box-hole.used{opacity:.4;cursor:default}
#modal .box-shard{display:inline-flex;align-items:center;gap:6px;min-height:48px;padding:0 14px;border:2px solid #8a6a2a;border-radius:6px 18px 6px 18px;background:linear-gradient(135deg,#2a2f3a,#0f1218);color:#dfe8f5;font:14px var(--serif);cursor:pointer}
#modal .box-shard.on{border-color:#fff;box-shadow:0 0 12px #9ec3ff88}
#modal .box-slots{display:grid;grid-template-columns:repeat(auto-fill,minmax(76px,1fr));gap:8px;margin:12px 0}
#modal .box-slot{display:flex;align-items:center;justify-content:center;gap:4px;min-height:52px;padding:0 6px;border:2px dashed #6b5a3a;border-radius:50%/40%;background:#0b0710;color:#cdbf9f;font:13px var(--serif);cursor:pointer}
#modal .box-slot.on{border-style:solid;border-color:var(--brass);color:var(--brass-hi);cursor:default}
#modal .box-slot.gap{opacity:.55}
#modal .box-keys{display:flex;flex-wrap:wrap;gap:6px;margin:0 0 10px;padding:0;list-style:none}
#modal .box-keys li{display:flex;align-items:center;gap:6px;padding:4px 10px;border:1px solid #6b5a3a;border-radius:4px;background:#120b17;font-size:13px;color:#e9dcc3}
#modal .box-keys small{color:#b8a07a}
#modal .box-keys b{font:20px var(--serif);color:var(--brass-hi)}
#modal .box-table{border-collapse:collapse;table-layout:fixed;width:100%;margin:6px 0 12px;font-size:11px;color:#9a8c70}
#modal .box-table caption{text-align:left;font-size:12px;color:#b8a07a;padding-bottom:2px}
#modal .box-table td{padding:1px 0;border:1px solid #3a2a14;text-align:center}
#modal .box-table td b{display:block;font-size:15px;color:#e9dcc3}
#modal .box-letter{margin:8px 0;padding:8px 10px;border:1px solid #3a2a14;border-radius:4px;background:#120b17}
#modal .box-pair{display:flex;align-items:center;justify-content:space-between;gap:6px;font-size:13px;color:#cdbf9f}
#modal .box-back b{font-size:18px;color:#fff}
#modal .box-sym{min-width:1.8em;padding:2px 8px;border:1px solid #6b5a3a;border-radius:4px;text-align:center;font:24px var(--serif);color:#e9dcc3}
#modal .box-sym.out{border-color:var(--brass);color:var(--brass-hi)}
#modal .box-from{display:block;margin:4px 0 0;font-size:11px;color:#b8a07a}
#modal .box-count{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px;margin-top:8px}
#modal .box-count .secondary-button{width:auto;min-width:0;min-height:44px;margin:0;padding:0}
#modal .box-word{font:26px var(--serif);letter-spacing:6px;color:var(--brass-hi)}
#modal .box-slot small{display:block;font-size:10px;color:#b8a07a}
#modal .box-slot.gap{flex-direction:column;gap:0}
#modal .box-pick{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-top:6px;font-size:12px;color:#cdbf9f}
#modal .box-pick select{min-height:44px;min-width:76px;font:inherit;color:#e9dcc3;background:#1d1a24;border:1px solid #3a3446;border-radius:4px}

/* Shadow cabin (E-X): the wall, the outline, the shadow, and the two turning dials */
#modal .sh-wall{fill:#0a0509;fill-opacity:.4;stroke:url(#bm-edge-brass);stroke-width:2}
#modal .sh-wall-shadow{fill:#000;fill-opacity:.4}
#modal .sh-pool{fill:url(#sh-pool);pointer-events:none}
#modal .sh-target{fill:url(#bm-brass);fill-opacity:.4;stroke:none}
#modal .sh-shade{fill:#07040a;fill-opacity:.94;stroke:none}
#modal .belfry-svg.matched .sh-target{fill-opacity:.75}
#modal .shadow-controls{display:grid;gap:10px;margin:12px 0}
#modal .shadow-slider{display:grid;grid-template-columns:96px 1fr 52px;align-items:center;gap:10px;min-height:44px;font-size:14px;color:var(--brass-hi)}
#modal .shadow-slider input{width:100%;min-height:44px;accent-color:var(--brass)}
#modal .shadow-slider output{text-align:right;font-variant-numeric:tabular-nums;color:#d9c9a4}
@media (max-width:480px){#modal .shadow-slider{grid-template-columns:78px 1fr 46px;gap:6px}}

/* Silent choir hall (E6): pipes, beat rows and the hymn grid */
#modal .choir-pipes{display:flex;flex-wrap:wrap;gap:8px;margin:10px 0}
#modal .choir-pipe{display:flex;flex-direction:column;align-items:center;gap:2px;min-width:56px;min-height:44px;padding:6px 6px 4px;border:1px solid var(--brass-mid);border-radius:4px;background:#17110c;color:#d9c9a4;cursor:pointer}
#modal .choir-pipe svg{width:32px;height:104px}
#modal .choir-pipe b{font-size:12px;font-weight:400}
#modal .choir-pipe[aria-pressed=true]{border-color:var(--brass-hi);background:#2a1f12;box-shadow:0 0 0 2px #c9ab6a50}
#modal .choir-cast{fill:#000;fill-opacity:.4}
#modal .choir-bar{fill:url(#bm-brass);stroke:#2a1704;stroke-width:.7}
#modal .choir-cyl{fill:url(#bm-cyl)}
#modal .choir-lit{fill:#ffd98a;fill-opacity:0}
#modal .choir-pipe[aria-pressed=true] .choir-lit{fill-opacity:.38}
#modal .choir-cap{fill:url(#bm-brass);stroke:url(#bm-edge-brass);stroke-width:.6}
#modal .choir-mouth{fill:#0c0608;stroke:#2a1704;stroke-width:.5}
#modal .choir-lip{fill:#ffe9a6;fill-opacity:.7}
#modal .choir-foot{fill:url(#bm-brass);stroke:#2a1704;stroke-width:.5}
#modal .choir-staff,#modal .choir-voice{display:grid;grid-template-columns:96px 1fr;align-items:center;gap:8px;margin:8px 0}
#modal .choir-voice{grid-template-columns:96px 44px 1fr 44px}
#modal .choir-label{font-size:13px;font-weight:400;color:var(--brass-hi);line-height:1.4}
#modal .choir-label small{display:block;font-size:11px;color:#9fb8a6}
#modal .choir-beats{display:flex;gap:3px}
#modal .choir-dot{flex:1;max-width:22px;height:22px;border:1px solid #5c4627;border-radius:50%;background:#0b0710}
#modal .choir-dot.lit{background:#e0b84f;border-color:#ffd98a}
#modal .choir-step{min-width:44px;min-height:44px;border:1px solid var(--brass-mid);border-radius:4px;background:#17110c;color:var(--brass-hi);font-size:20px;cursor:pointer}
#modal .choir-facts{margin:6px 0 10px;padding-left:18px;font-size:13px;line-height:1.8;color:#d9c9a4}
#modal .choir-grid{display:grid;grid-template-columns:72px repeat(3,1fr);gap:6px;margin:10px 0}
#modal .choir-grid-head,#modal .choir-grid-beat{font-size:12px;color:var(--brass-hi);align-self:center;text-align:center}
#modal .choir-cell{min-height:44px;border:1px solid var(--brass-mid);border-radius:4px;background:#17110c;cursor:pointer}
#modal .choir-cell[aria-pressed=true]{background:#e0b84f;border-color:#ffd98a}
@media (max-width:480px){#modal .choir-staff{grid-template-columns:64px 1fr}#modal .choir-voice{grid-template-columns:64px 44px 1fr 44px;gap:4px}#modal .choir-dot{height:16px}}

/* Weighing hall (E7): balanced pages, the open scale and its steppers */
#modal .scale-pages{list-style:none;margin:10px 0;padding:0;display:grid;gap:8px}
#modal .scale-recall{margin:10px 0}
#modal .scale-recall summary{min-height:44px;display:flex;align-items:center;cursor:pointer;color:var(--brass-hi);font-size:13px}
#modal .scale-row{display:grid;grid-template-columns:1fr 28px 1fr;align-items:center;gap:6px;padding:8px;border:1px solid #3b2d1a;border-radius:4px;background:#120c10}
#modal .scale-pan{display:flex;flex-wrap:wrap;align-items:flex-end;gap:2px;min-height:46px}
#modal .scale-right{justify-content:flex-start}
#modal .scale-eq{text-align:center;color:var(--brass-hi);font-size:18px}
#modal .scale-sym{width:46px;height:46px;filter:drop-shadow(0 2px 2px #000a)}
#modal .scale-sym.sym-rose{filter:drop-shadow(0 0 3px #cdb6f0cc) drop-shadow(0 2px 2px #000a)}
#modal .scale-lb{display:inline-flex;align-items:center;justify-content:center;min-width:58px;height:54px;padding:12px 6px 0;background:url(assets/puzzles/scale-weight.webp) center/contain no-repeat;color:#e6e6ee;font-size:12px;font-weight:700;text-shadow:0 1px 2px #000}
#modal .scale-open{margin:12px 0 6px}
#modal .scale-row.open{border-color:var(--brass-mid)}
#modal .scale-steppers{display:grid;gap:6px;margin:8px 0}
#modal .scale-stepper{display:grid;grid-template-columns:46px 1fr 44px 36px 44px;align-items:center;gap:6px;color:#d9c9a4;font-size:14px}
#modal .scale-stepper output{text-align:center;font-variant-numeric:tabular-nums}
@media (max-width:480px){#modal .scale-sym{width:36px;height:36px}#modal .scale-row{grid-template-columns:1fr 20px 1fr;padding:6px}}

/* Frozen moments (E8 prototype): a row of masked guests drawn from data, a clue list and one select per place */
#modal .frz-clues{margin:8px 0;padding-left:20px;font-size:13px;line-height:1.8;color:#d9c9a4}
#modal .frz-scene{display:block;width:100%;max-width:520px;margin:8px auto;border:2px solid var(--brass);border-radius:4px;background:#120c10;box-shadow:inset 0 0 0 2px #0b0806,0 0 0 3px #17110c,0 0 0 4px #c9ab6a40,0 12px 30px #000a}
#modal .frz-scene[data-n="2"]{max-width:300px}
#modal .frz-wall{fill:#1c0d14}
#modal .frz-glow{fill:url(#bm-candle)}
#modal .frz-floor{fill:#0a0508;fill-opacity:.35}
#modal .frz-cast{fill:#000;fill-opacity:.5}
#modal .frz-plate{fill:url(#bm-brass);stroke:url(#bm-edge-brass);stroke-width:1}
#modal .frz-num{fill:#2a1608;font-size:10px;font-weight:700;text-anchor:middle}
#modal .frz-slots{display:grid;grid-template-columns:repeat(auto-fit,minmax(92px,1fr));gap:6px;margin:8px 0}
#modal .frz-slot{display:flex;flex-direction:column;gap:2px;font-size:12px;color:var(--brass-hi)}
#modal .frz-slot select{min-height:44px;border:1px solid var(--brass-mid);border-radius:4px;background:#17110c;color:#d9c9a4;font-size:14px}
#modal .frz-frame{margin:8px 0}
#modal .frz-frame figcaption{font-size:13px;color:var(--brass-hi);margin-bottom:2px}
#modal .frz-glass{fill:#bfe3ff30;stroke:#e6f4ff;stroke-width:1.2;stroke-linecap:round;stroke-linejoin:round}
#modal .frz-wine{fill:#8a1226;stroke:none}
#modal .frz-recall{margin:10px 0}
#modal .frz-recall summary{min-height:44px;display:flex;align-items:center;cursor:pointer;color:var(--brass-hi);font-size:13px}
#modal .frz-roster{margin:6px 0;padding-left:18px;font-size:13px;line-height:1.8;color:#d9c9a4}
#modal .frz-held{fill:url(#bm-pin);stroke:#fff0b8;stroke-width:1.6}

/* Mirror compass (E9): concentric rings turned with buttons, a needle at the top, a pad of turn buttons per ring */
#modal .cmp-rule{margin:6px 0;font-size:13px;color:#d9c9a4}
#modal .cmp-stage{max-width:340px;margin:8px auto}
#modal .cmp-dial{display:block;width:100%;height:auto}
#modal .cmp-stage{border-radius:50%;background:radial-gradient(circle,#0f0a0c 0 58%,#0f0a0c00 72%)}
#modal .cmp-band,#modal .cmp-band-tint,#modal .cmp-band-shadow{fill:none}
#modal .cmp-band-tint{opacity:.5;mix-blend-mode:color}
#modal .cmp-band-shadow{stroke:#000;stroke-opacity:.42}
#modal .cmp-band-lit{fill:none;stroke:#fff0b8;stroke-opacity:.5;stroke-width:1}
#modal .cmp-band-dark{fill:none;stroke:#1d1004;stroke-opacity:.75;stroke-width:1.2}
#modal .cmp-rim{fill:url(#bm-brass);stroke:url(#bm-edge-brass);stroke-width:1.6}
#modal .cmp-rim-shadow{fill:#000;fill-opacity:.4}
#modal .cmp-core{fill:#150d0c;stroke:url(#bm-edge-brass);stroke-width:1.4}
#modal .cmp-core-lit{fill:url(#bm-web);stroke:#c9a95a;stroke-opacity:.35;stroke-width:.8}
#modal .cmp-star{fill:url(#bm-brass);stroke:#3a2508;stroke-width:.6;opacity:.8}
#modal .cmp-pin{fill:url(#bm-pin);stroke:#2a1a05;stroke-width:1}
#modal .cmp-ring{transform-origin:150px 150px;transition:transform .34s cubic-bezier(.3,1.25,.5,1)}
#modal .cmp-glyph{transition:transform .34s cubic-bezier(.3,1.25,.5,1)}
#modal .cmp-still .cmp-ring,#modal .cmp-still .cmp-glyph,body.reduce-motion #modal .cmp-ring,body.reduce-motion #modal .cmp-glyph{transition:none}
#modal .cmp-shape{fill:url(#bm-pin);stroke:#2a1704;stroke-width:.7;stroke-linejoin:round}
#modal .cmp-mark-disc{fill:url(#bm-pin);stroke:#ffe9a6;stroke-width:1.2}
#modal .cmp-mark{fill:#2a1608;font-size:15px;font-weight:700}
#modal .cmp-needle{fill:url(#bm-needle);stroke:#f3e6c4;stroke-width:1.2;stroke-linejoin:round}
#modal .cmp-needle-line{stroke:#e0505a;stroke-width:1.4;stroke-dasharray:3 3}
#modal .cmp-pad{display:grid;gap:6px;margin:8px 0}
#modal .cmp-row{display:grid;grid-template-columns:1fr 64px 1fr;gap:6px;align-items:center}
#modal .cmp-turn{min-height:44px;border:1px solid var(--brass-mid);border-radius:4px;background:#17110c;color:var(--brass-hi);font-size:22px;cursor:pointer}
#modal .cmp-turn:focus-visible{outline:2px solid var(--brass-hi);outline-offset:2px}
#modal .cmp-name{text-align:center;color:var(--brass-hi);font-size:15px}

/* Snow White mechanisms, painted parts (2026-10-15). The rules and click areas are unchanged; what you see is generated art
   (assets/puzzles, local Z-Image Turbo) on top of the same markup. Motion comes from class changes the boards now patch in place
   (puzzles/morph.js), so every move plays a transition instead of redrawing the board. */
#modal{--plate:linear-gradient(rgba(10,6,3,.82),rgba(10,6,3,.9)),url(assets/puzzles/watch-plate.webp) center/cover}

/* Birth record: torn pieces of one painted sheet. */
#modal .ledger-board{gap:3px;padding:8px;background:#0a0705 url(assets/puzzles/mat-steel.webp) 0 0/72px 72px;background-blend-mode:multiply}
#modal .ledger-tile{border:1px solid #2a1c0d;border-radius:1px;background:#d8c59c;box-shadow:inset 0 0 12px rgba(58,28,8,.5),0 1px 0 #000a;transition:transform .16s cubic-bezier(.3,1.4,.5,1),box-shadow .16s,border-color .16s}
#modal .ledger-tile.placed{border-color:#c9ab6aaa;box-shadow:inset 0 0 10px rgba(58,28,8,.35),0 0 0 1px #c9ab6a55}
#modal .ledger-tile.selected{transform:translateY(-3px) scale(1.04);border-color:#f0dca8;box-shadow:inset 0 0 0 1px #f0dca8,0 8px 16px #000b;filter:none;z-index:2}
#modal .ledger-tile:focus-visible{outline:2px solid var(--brass-hi);outline-offset:1px;z-index:3}
.ledger-rule{stroke:#5a3a1c;opacity:.5}
.ledger text{fill:#2a1a0c}
/* Birth-record scroll type: LXGW WenKai TC (kai hand) and IM Fell English (old-style roman), both SIL OFL 1.1, subset to the characters the ledger uses. */
@font-face{font-family:'Scroll Kai';font-weight:400;font-display:swap;src:url(assets/fonts/wenkai-400.woff2) format('woff2')}
@font-face{font-family:'Scroll Kai';font-weight:700;font-display:swap;src:url(assets/fonts/wenkai-700.woff2) format('woff2')}
@font-face{font-family:'Scroll Roman';font-weight:400;font-display:swap;src:url(assets/fonts/fell-400.woff2) format('woff2')}
.ledger .ledger-latin{font-family:'Scroll Roman',Georgia,serif;font-size:11px;letter-spacing:3.4px;fill:#6b4a1f}
.ledger .ledger-title{font-weight:700;font-size:25px;letter-spacing:4px}
.ledger .ledger-small{font-size:11.5px;letter-spacing:1.4px;fill:#4a2f14}
.ledger .ledger-line{font-size:17px;letter-spacing:2.5px}
.ledger-page{height:auto}
#modal .ledger-figure{width:min(100%,390px);border:0;border-radius:0;box-shadow:none;background:none}

/* Pocket watch: a brass movement plate under three painted gears. */
#modal .watch-board{background:linear-gradient(rgba(10,6,3,.58),rgba(10,6,3,.72)),url(assets/puzzles/watch-plate.webp) center/cover;border:2px solid var(--brass);box-shadow:inset 0 0 0 2px #0b0806,inset 0 0 30px #000d,0 0 0 4px #17110c,0 0 0 5px #c9ab6a55,0 14px 36px #000a}
/* Wheels are 92px wide for a 100-unit box: tip 42.3px, root 35px. Centres sit 77.3px apart (92 - 2 x 7.35), i.e. tip + root, so teeth meet grooves. */
.gear-frame{position:relative;display:block;width:92px;height:92px;filter:none}
.gear-svg{display:block;width:100%;height:100%;overflow:visible}
.gear-body{fill:url(#bm-brass);stroke:url(#bm-edge-brass);stroke-width:.7;stroke-linejoin:round}
.gear-hole{fill:url(#bm-hole);stroke:#e7c978;stroke-opacity:.5;stroke-width:.5}
.gear-spokes{fill:url(#bm-brass);stroke:url(#bm-edge-brass);stroke-width:.5;stroke-linejoin:round}
.gear-hub{fill:url(#bm-pin);stroke:#3a2508;stroke-width:.5}
.gear-axle{fill:#1b1005}
.gear-shade{position:absolute;left:4%;top:4%;width:92%;height:92%;border-radius:50%;background:radial-gradient(circle at 34% 30%,rgba(255,246,216,.3),rgba(255,255,255,0) 45%,rgba(26,12,2,.45));pointer-events:none}
.gear-ruby{position:absolute;left:50%;top:21%;width:15%;height:15%;transform:translate(-50%,-50%);background:url(assets/puzzles/wheel-ruby.webp) center/contain no-repeat;border-radius:50%;opacity:.72;transition:opacity .25s,box-shadow .25s}
.watch-gear.aligned .gear-ruby{opacity:1;box-shadow:0 0 8px 2px rgba(255,92,112,.85)}
.watch-gear:focus-visible .gear-art{outline:2px solid #f0dca8;outline-offset:-4px;border-radius:50%}

/* Steam pipes: copper tiles, each pipe drawn in its turn-0 pose and rotated by the board. */
#modal .pipes-board{background:#0a0705 url(assets/puzzles/mat-steel.webp) 0 0/72px 72px;background-blend-mode:multiply}
#modal :is(.pipe-piece,.pipe-terminal){background:radial-gradient(ellipse,#2c2019,#110d10)}
#modal .pipe-piece.flowing,#modal .pipe-terminal.flowing{background:radial-gradient(circle at 50% 50%,rgba(105,212,208,.2),transparent 70%),radial-gradient(ellipse,#2c2019,#110d10)}
#modal .pipe-piece:hover{background:radial-gradient(circle at 50% 50%,rgba(240,220,168,.14),transparent 72%),radial-gradient(ellipse,#3a2a20,#17110f)}
#modal .pipe-glyph{background-position:center;background-size:100% 100%;background-repeat:no-repeat;transition:transform .2s cubic-bezier(.3,1.35,.5,1)}
.pipe-straight{background-image:url(assets/puzzles/pipe-straight.webp)}
.pipe-elbow{background-image:url(assets/puzzles/pipe-elbow.webp)}
/* the open ends of a run reach past the tile edge so the edge is a straight cut */
#modal :is(.pipe-straight,.pipe-elbow){background-size:110% 110%}
.pipe-source{background-image:url(assets/puzzles/pipe-source.webp)}
.pipe-city{background-image:url(assets/puzzles/pipe-city.webp)}
.pipe-terminal .pipe-glyph{position:absolute;inset:0}
#modal :is(.pipe-piece,.pipe-terminal).flowing{box-shadow:inset 0 0 22px rgba(105,212,208,.42),inset 0 0 0 1px rgba(105,212,208,.35)}

/* Mirror corridor: silvered walls, marble floor, one gold reflection that slides. */
#modal .maze-board{position:relative;gap:0;padding:6px}
#modal .maze-cell{background:url(assets/puzzles/mirror-floor.webp) 0 0/200% 100%;border:1px solid #1d150d;border-radius:0}
#modal .maze-cell:nth-child(even){background-position:100% 0}
#modal .maze-cell.wall{background:linear-gradient(135deg,rgba(150,180,220,.22),rgba(14,24,40,.5)),url(assets/puzzles/mirror-glass.webp) center/cover;border-color:#5b6b80;box-shadow:inset 0 0 8px #0009}
#modal .maze-cell.gate{background:radial-gradient(circle,rgba(255,200,120,.22),transparent 72%),url(assets/puzzles/mirror-floor.webp) 0 0/200% 100%;border-color:var(--brass)}
#modal .maze-cell.gate::after,#modal .maze-cell.exit::after{content:'';position:absolute;inset:8%;background:center/contain no-repeat}
#modal .maze-cell{position:relative}
#modal .maze-cell.gate::after{background-image:url(assets/puzzles/maze-hourglass.webp)}
#modal .maze-cell.exit{border-color:var(--ruby)}
#modal .maze-cell.exit::after{background-image:url(assets/puzzles/maze-door.webp)}
#modal .maze-cell.here{background:radial-gradient(circle,rgba(240,200,110,.28),transparent 72%),url(assets/puzzles/mirror-floor.webp) 0 0/200% 100%;box-shadow:none;border-color:#3a2c1a}
.maze-token{position:absolute;left:6px;top:6px;width:calc((100% - 12px)/7);height:calc((100% - 12px)/5);z-index:2;pointer-events:none;background:url(assets/puzzles/maze-token.webp) center/78% no-repeat,radial-gradient(circle,rgba(240,200,110,.5),transparent 68%);transform:translate(calc(var(--c)*100%),calc(var(--r)*100%));transition:transform .2s cubic-bezier(.3,1.2,.5,1)}
.maze-token.r0{--r:0}.maze-token.r1{--r:1}.maze-token.r2{--r:2}.maze-token.r3{--r:3}.maze-token.r4{--r:4}
.maze-token.c0{--c:0}.maze-token.c1{--c:1}.maze-token.c2{--c:2}.maze-token.c3{--c:3}.maze-token.c4{--c:4}.maze-token.c5{--c:5}.maze-token.c6{--c:6}
.maze-arrow{display:block;width:100%;height:100%;background:url(assets/ui/arrow-medal.webp) center/contain no-repeat;transition:transform .12s}
.maze-U .maze-arrow{transform:rotate(-90deg)}.maze-D .maze-arrow{transform:rotate(90deg)}.maze-L .maze-arrow{transform:scaleX(-1)}
#modal .maze-key{padding:6px;background:none;border:0;box-shadow:none;filter:drop-shadow(0 2px 5px #000a);transition:transform .08s,filter .12s}
#modal .maze-key:hover{filter:drop-shadow(0 2px 5px #000a) brightness(1.18)}
#modal .maze-key:active{transform:scale(.92);box-shadow:none}


/* Coffin heartbeat: four brass plates; the one that flashes turns ruby. */
#modal .rune-key{background:linear-gradient(rgba(20,12,6,.3),rgba(20,12,6,.55)),url(assets/puzzles/watch-plate.webp) center/cover;transition:background .12s,box-shadow .12s,transform .08s}
#modal .rune-key.illuminated{background:radial-gradient(circle at 50% 38%,#ff9aa7,var(--ruby) 62%,#5a1220);transform:scale(1.04)}

/* Memory cards: a painted back, an aged-paper face. */
#modal .memory-card{background:url(assets/puzzles/card-back.webp) center/100% 100% no-repeat;border:0;border-radius:6px;color:transparent;text-shadow:none;box-shadow:0 3px 7px #000b;transition:transform .12s}
#modal .memory-card:active{transform:scale(.96)}
#modal .memory-card.turned{background:linear-gradient(rgba(70,40,18,.1),rgba(70,40,18,.28)),url(assets/puzzles/ledger-sheet.webp) center/260% auto;border:2px solid var(--brass-hi);color:#2a1a0c;box-shadow:inset 0 0 12px rgba(58,28,8,.55);animation:card-turn .26s cubic-bezier(.3,1.2,.5,1)}
#modal .memory-card.turned .memory-text{color:#2a1a0c;font-weight:600}
#modal .memory-card.turned .memory-symbol{color:#3a220e}
@keyframes card-turn{from{transform:rotateY(80deg) scale(.96)}to{transform:none}}

/* Mirror light path: framed mirrors that swing, a lit door. */
#modal .light-mirror{position:relative;background:var(--plate);overflow:hidden;color:transparent;font-size:0}
#modal .light-mirror::before{content:'';position:absolute;left:-6%;top:42%;width:112%;height:17%;background:url(assets/puzzles/mirror-strip.webp) center/100% 100% no-repeat;transform:rotate(-45deg);transition:transform .22s cubic-bezier(.3,1.35,.5,1)}
#modal .light-mirror.o1::before{transform:rotate(45deg)}
#modal .light-mirror.beam{background:linear-gradient(rgba(70,100,140,.4),rgba(30,44,60,.5)),var(--plate);box-shadow:inset 0 0 14px rgba(188,208,232,.55),0 0 8px rgba(188,208,232,.3)}
#modal .light-door{position:relative;font-size:0;background:var(--plate)}
#modal .light-door::after{content:'';position:absolute;inset:6%;background:url(assets/puzzles/maze-door.webp) center/contain no-repeat;filter:saturate(.55) brightness(.75);transition:filter .3s}
#modal .light-door.open{background:radial-gradient(circle,rgba(255,138,150,.55),transparent 75%),var(--plate);box-shadow:0 0 20px #ff738599}
#modal .light-door.open::after{filter:saturate(1.3) brightness(1.2) drop-shadow(0 0 8px #ff7385)}
#modal .light-cell:not(.light-mirror):not(.light-door){background:var(--plate)}
#modal .light-cell.beam:not(.light-mirror){background:linear-gradient(rgba(70,100,140,.35),rgba(30,44,60,.45)),var(--plate)}

/* Cloth and plate cells: stitches, reflections and rubbing patches share one dark engraved plate. */
#modal :is(.stitch-cell,.reflection-cell){background:var(--plate)}
#modal .stitch-cell.on{background:radial-gradient(circle at 36% 30%,#d4485c,#8c2433 55%,#4a0f1a);box-shadow:inset 0 0 8px #0008,0 0 8px #a6536055;transition:background .2s}
#modal .reflection-cell{transition:background .25s,color .25s,text-shadow .25s}
#modal .reflection-cell.glow{background:radial-gradient(ellipse,rgba(234,164,197,.55),rgba(44,28,44,.2) 80%),var(--plate)}
#modal .rub-cell{background:var(--plate);transition:background .3s,color .3s}
#modal .rub-cell.clear{background:linear-gradient(rgba(70,40,18,.06),rgba(70,40,18,.3)),url(assets/puzzles/ledger-sheet.webp) center/340% auto;color:#2e2016}

/* Music box: painted brass levers on a perlage plate. */
#modal .musicbox-pins{background:linear-gradient(rgba(10,6,3,.55),rgba(10,6,3,.72)),url(assets/puzzles/watch-plate.webp) center/cover}
#modal .music-pin{width:44px;height:104px;border:0;border-radius:0;background:url(assets/puzzles/pin.webp) center/contain no-repeat;box-shadow:none;font-size:0;color:transparent;transition:transform .18s cubic-bezier(.3,1.5,.5,1)}
#modal .music-pin.raised{background:url(assets/puzzles/pin.webp) center/contain no-repeat,radial-gradient(ellipse at 50% 55%,rgba(255,115,133,.6),transparent 72%);box-shadow:none;transform:translateY(-16px)}
@media (prefers-reduced-motion:reduce){
 #modal :is(.ledger-tile,.pipe-glyph,.heart-node,.memory-card,.rune-key,.music-pin,.maze-key){transition:none}
 #modal .light-door::after{transition:none}
 .maze-token,#modal .memory-card.turned{transition:none;animation:none}
 #modal .light-mirror::before{transition:none}
}

/* Guest masks and miners' beds: each select sits in a painted bronze nameplate (assets/puzzles/nameplate.webp, 560x138).
   The plate is a 9-slice border image, so the rivets stay round at any width; a small brass chevron stands in for the native arrow. */
#modal .mask-row{position:relative}
#modal .mask-row select{appearance:none;-webkit-appearance:none;min-height:50px;padding:0 34px 0 16px;border:0;border-radius:0;background:none;box-shadow:none;
 border-image:url(assets/puzzles/nameplate.webp) 38 60 fill/13px 20px stretch;color:var(--brass-hi);font-family:'Scroll Kai','LL Serif TC','Noto Serif TC',serif;font-size:15px;letter-spacing:1px;text-shadow:0 1px 0 #000a;cursor:pointer}
#modal .mask-row::after{content:'';position:absolute;right:22px;top:50%;width:6px;height:6px;border:solid var(--brass-hi);border-width:0 1.5px 1.5px 0;transform:translateY(-70%) rotate(45deg);pointer-events:none;opacity:.85}
#modal .mask-row select:hover{filter:brightness(1.12)}
#modal .mask-row select:focus-visible{outline:2px solid var(--brass-hi);outline-offset:3px}
/* Painted objects on the aged-paper face: a soft shadow keeps the white feather readable. The sprites never move, so a filter is fine here. */
#modal .memory-card.turned .concept-sprite{filter:drop-shadow(0 2px 3px rgba(40,20,5,.55))}
