/* Shared layout contract. Keep puzzle geometry and hit testing untransformed. */
:root{--ui-gap:8px;--ui-inset:16px;--ui-radius:5px;--ui-control:44px}
:is(#companion,#second-shift,#domino,#test-room) .header{min-height:56px;padding:0 0 7px;gap:6px;margin:0;border-bottom-width:2px;align-items:center}
:is(#companion,#second-shift,#domino,#test-room) .header h1{font-size:26px;line-height:1.05;overflow-wrap:break-word}
.header .game-brand{flex:1;min-width:0;gap:6px}
.header .tools{gap:2px;flex:none}
:is(#companion,#second-shift,#domino,#test-room) .header .icon-button{width:44px;min-width:44px;height:44px;min-height:44px;padding:8px;border-width:1px;box-shadow:1px 2px var(--print-ink);border-radius:var(--ui-radius)}
.header .brand .eyebrow{font-size:10px;line-height:12px;margin-top:2px}
:is(#companion,#second-shift,#domino,#test-room) .puzzle-context{min-height:44px;padding:0;margin:0 0 6px;gap:6px;border-bottom-width:1px}
.puzzle-context button{min-height:44px}
#domino .dm-stage{max-height:min(440px,calc(100vw - 32px))}
#companion[data-game=patchwork] .comp-stage{max-height:min(380px,calc((100vw - 32px)*.8))}
#companion[data-game=equal] .comp-stage{max-height:480px}
#test-room{padding-inline:max(12px,env(safe-area-inset-left));padding-bottom:max(12px,env(safe-area-inset-bottom))}
#test-room .prototype-meta{min-height:20px;margin:0 0 8px;font-size:11px}
#test-room :is(.prototype-controls,.pk-tools){padding-top:8px;margin-top:8px;min-height:52px;gap:8px}
#test-room :is(.prototype-controls,.pk-tools)>span{font-size:11px;line-height:1.3}
#test-room .pk-tools>[data-action=puzzle-undo]{display:none}
#test-room .pk-tools:not(:has(>button:not([data-action=puzzle-undo]))){min-height:24px;padding-top:6px;justify-content:center}
#test-room .lab-status{margin:8px 0 0;font-size:12px;line-height:17px;min-height:0}
#test-room .lab-actions{margin:8px 0}
#test-room .pk-palette{margin-top:10px;gap:7px}
#test-room [data-test-game=stackerz] .pk-palette button{width:48px;height:48px;min-height:44px}
#test-room .planet-ledger{grid-template-columns:repeat(3,minmax(0,1fr));gap:4px 6px;margin-top:8px}
#test-room .planet-ledger>div{display:grid;grid-template-columns:10px 1fr;gap:2px 5px;min-height:32px;padding:3px 0;font-size:11px}
#test-room .planet-ledger i{width:9px;height:9px;grid-row:1/3}
#test-room .planet-ledger span{grid-column:2;margin:0;font-size:10px}
#test-room .tower-ledger{margin-top:8px;gap:6px}
#test-room .tower-ledger>span{padding:6px 2px;font-size:10px}
#test-room [data-test-game=phrase] .phrase-board{min-height:0;padding:10px 0 12px;gap:8px 12px}
#test-room .notwof-score{padding:2px 0 8px}
#test-room .notwof-score strong{font-size:32px}
#test-room .notwof-category{margin:10px 0 4px}
#test-room .notwof-letter-values{padding:7px 0}
#test-room .notwof-solve{margin-top:8px}
#test-room .trivia-question{font-size:21px;line-height:1.3;margin-block:12px}
#test-room .trivia-answers{gap:8px}
#test-room .trivia-answers button{min-height:48px;padding:9px 10px;gap:8px;font-size:14px}
#test-room .trivia-meta{min-height:22px;margin-bottom:6px;font-size:11px}
#test-room .question-progress{margin:6px 0 10px}
#test-room .trivia-question{min-height:0}
#test-room .tone-sliders label{padding:5px 0}
#test-room .tone-sliders{gap:4px;padding:4px 0}
#test-room .tone-sliders label{display:grid;grid-template-rows:18px 44px;gap:0;padding:0;line-height:18px}
#test-room .tone-sliders input{height:44px;min-height:44px;margin:0}
#test-room .tone-meta{min-height:24px;margin:0 0 6px;padding:0;font-size:11px}
#test-room .tone-photo-tabs{margin:8px 0}
#test-room .tone-credit{margin-top:8px}
#test-room :is(.pipe-board,.towers-board,.pk-frame,.pk-network,.pk-grid):not(.pk-frame *){margin-inline:auto}
#test-room .pk-frame .pk-grid{max-width:none}
/* One shell for short prompts and long, scrollable sheets. */
body dialog:not(.studio-splash):not(.abstract-dialog){--ink:#242320;--muted:#625f58;--line:#d8d2c3;--paper-face:#fff9e9;color:var(--ink);background-color:var(--paper-face);border:2px solid var(--print-ink);border-radius:var(--ui-radius);box-shadow:4px 5px 0 var(--print-ink);width:min(540px,calc(100% - 24px));max-width:calc(100% - 24px);max-height:calc(var(--visible-height,100dvh) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 24px);margin:auto;padding:16px;overflow:auto;overscroll-behavior:contain;scroll-padding-block:64px 16px}
body dialog:not(.studio-splash)::backdrop{background:#24232099;backdrop-filter:none}
body dialog:not(.studio-splash) :is(.settings-heading,.sheet-heading,.access-heading,.statistics-header,.launch-heading){position:sticky;top:-16px;z-index:4;display:flex;align-items:center;justify-content:space-between;gap:12px;background:var(--paper-face);padding:10px 0;margin:0 0 12px;border-bottom:2px solid var(--print-ink)}
body dialog:not(.studio-splash) :is(.settings-heading,.sheet-heading,.access-heading,.statistics-header,.launch-heading) h2{font:400 28px/1.1 var(--hand);margin:0;overflow-wrap:anywhere}
body dialog:not(.studio-splash) .icon-button{width:44px;min-width:44px;height:44px;min-height:44px;flex:0 0 44px;border:1px solid var(--print-ink);border-radius:var(--ui-radius);background:#eee8d8;box-shadow:1px 2px var(--print-ink);color:var(--ink);padding:10px}
body dialog:not(.studio-splash) .icon-button svg{width:20px;height:20px}
body dialog:not(.studio-splash) :is(.primary-button,.secondary-button,.dialog-actions button){min-height:44px;border-radius:var(--ui-radius);font-size:14px;padding:10px 12px;line-height:1.35;white-space:normal}
body :is(#statistics-dialog,#leaderboard-dialog,#plus-dialog){height:auto;width:min(540px,calc(100% - 24px));max-width:calc(100% - 24px);max-height:calc(var(--visible-height,100dvh) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 24px);padding:0 16px 16px;border:2px solid var(--print-ink);border-radius:var(--ui-radius);box-shadow:4px 5px var(--print-ink)}
body :is(#statistics-dialog,#leaderboard-dialog,#plus-dialog) :is(.statistics-header,.launch-heading){top:0;padding:12px 0}
#statistics-dialog .statistics-content,#leaderboard-dialog .rank-content,#plus-dialog .plus-content{padding:0}
#plus-dialog .plus-cover{padding:0 0 12px}
#plus-dialog .plus-art{height:104px;margin-block:8px}
#plus-dialog .plus-plan{min-height:112px;gap:6px}
#plus-dialog .plus-benefits{margin-bottom:12px}
#plus-dialog .plus-benefits li{padding-block:5px}
#settings-dialog .settings-row{padding-block:10px;min-height:48px}
body #pause-menu{width:min(380px,calc(100% - 24px))}
body #shelf-piece-dialog{width:min(540px,calc(100% - 24px));padding:16px;border-width:2px;border-radius:var(--ui-radius);box-shadow:4px 5px var(--print-ink)}
.shelf-picker-heading{border-bottom:2px solid var(--print-ink);padding-bottom:10px}
.shelf-picker-heading h2{font-size:28px}
#pause-menu header{display:flex;align-items:center;justify-content:space-between;border-bottom:2px solid var(--print-ink);padding-bottom:10px;margin-bottom:8px}
#pause-menu header h2{margin:0;font-size:28px}
#pause-menu nav button{min-height:48px;padding:8px;border-radius:0;box-shadow:none}
body #success-dialog{padding:14px 16px}
#success-dialog .success-burst{height:76px;margin:0 44px 4px;animation-duration:220ms}
#success-dialog h2{font-size:42px}
#success-dialog .success-close{position:sticky;top:0;float:right;margin:0 0 -44px;z-index:5}
#success-dialog .success-game{margin:6px 0 10px}
#success-dialog .success-now{padding:10px 0}
#success-dialog .success-now strong{font-size:27px}
#success-dialog .success-averages{margin-top:10px}
#success-dialog .success-averages :is(th,td){padding-block:5px}
#success-dialog .success-actions{gap:8px}
#success-dialog .success-actions button{padding:9px 10px;min-height:44px;font-size:13px;white-space:normal}
#success-dialog .success-note{margin:7px 0;font-size:11px}
#success-dialog :is(.success-online,.success-daily){padding:8px 0;margin:8px 0}
#home .tier-heading{height:auto;min-height:68px}
#home .ritual-card h2{height:auto;min-height:34px;margin:6px 0 8px;font-size:30px;line-height:1.05}
#home .ritual-card{min-height:0;padding:12px 12px 10px}
#home .tier-games{grid-template-rows:repeat(2,minmax(112px,auto));gap:8px}
#home .tier-game{min-height:112px;padding:8px 5px;gap:4px}
#home .tier-art{width:40px;height:40px;flex-basis:40px}
#home .tier-game-copy strong{min-height:32px;font-size:13px;line-height:16px}
#home .library-heading{padding-top:16px;margin-top:16px}
#home .library-allowance{margin-block:6px 12px}
/* Beta games inherit the same compact typography and touch-sized controls. */
.abstract-header{gap:8px;padding-bottom:8px}
.abstract-header h2{font-size:26px}
.abstract-difficulty{margin:8px 0;gap:6px}
.abstract-hud{margin-bottom:8px;padding-block:5px}
.abstract-target{width:76px;margin-bottom:10px}
.abstract-status{margin:8px 0;min-height:18px}
.abstract-tools{padding-top:8px;gap:10px}
.abstract-rules{margin:6px 0}
.abstract-grid{max-width:min(100%,calc(var(--visible-height,100dvh) - 340px));margin-inline:auto;gap:6px}
.thread-board{max-width:min(100%,calc(var(--visible-height,100dvh) - 280px))}
.slide-controls{margin-top:10px}
@media(max-width:380px){
 :is(#companion,#second-shift,#domino,#test-room) .header{display:grid;grid-template-columns:44px 1fr;gap:4px}
 .header .game-brand{display:contents}
 .header .game-brand .brand{grid-column:1/-1;grid-row:1}
 .header .tools{grid-column:2;grid-row:2;justify-self:end}
 :is(#companion,#second-shift,#domino,#test-room) .header h1{font-size:23px}
 .header .game-brand>.icon-button{grid-column:1;grid-row:2;margin:0}
 .header .brand .eyebrow{display:none}
 #test-room .planet-ledger>div{gap:2px 3px;font-size:10px}
 #test-room .signal-number{font-size:19px}
 #home .ritual-card h2{font-size:28px}
}
@media(max-height:700px){
 #test-room .tone-meta{padding:0}
 #test-room [data-test-game=phrase] .phrase-board span{height:30px;width:24px;font-size:16px}
 .abstract-grid{gap:4px}.abstract-target{width:60px}
 .abstract-board-label{margin:5px 0}.abstract-tools{padding-top:6px}
 .stack-board{min-height:200px}.balance-beam{height:52px}
}
@media(max-width:380px) and (max-height:650px){
 #test-room .trivia-question{font-size:18px;line-height:1.3;margin-block:8px}
 #test-room .trivia-answers button{padding:7px 8px;min-height:46px;line-height:19px}
 #test-room [data-test-game=phrase] .phrase-board{gap:5px 8px;padding:7px 0}
 #test-room [data-test-game=phrase] .phrase-board span{width:20px;height:25px;font-size:15px}
 #test-room .notwof-score strong{font-size:26px}
 #test-room .notwof-letter-values{padding:5px 0}
 #test-room .notwof-letter-values b{display:inline;margin-left:4px}
 #test-room [data-test-game=phrase] .lab-keyboard{margin:4px 0 4px}
 #test-room .notwof-solve{margin-top:4px}
 #test-room .notwof-category{margin:6px 0 2px}
 #test-room .planet-ledger strong{font-size:9px;white-space:nowrap}
 #test-room .planet-ledger span{font-size:9px}
}
@media(prefers-reduced-motion:reduce){body dialog:not(.studio-splash){animation:none;transition:none}}
