/* Enamel trays, printed order tickets, and a little flour on the counter. */
.puzzle-page{--p-ink:#244c40;--p-paper:#fff6df;--p-rim:#527d67;--p-tile:#eadbb8;--p-line:#c7b78f;--p-accent:#bd4e33;--p-shadow:#173c32;--p-muted:#6d6958}
[data-theme=dark] .puzzle-page{--p-ink:#f6e6bd;--p-paper:#263b34;--p-rim:#3c6856;--p-tile:#354a3e;--p-line:#59705d;--p-accent:#f3b47d;--p-shadow:#0c211c;--p-muted:#b9bc9f}
.puzzle-page[data-puzzle=slice]{--p-rim:#a8604e}.puzzle-page[data-puzzle=tray]{--p-rim:#447381}
.puzzle-heading{display:flex;justify-content:space-between;align-items:end;gap:20px;margin:24px 0}.puzzle-heading h1{font-family:Georgia,'Noto Serif TC',serif;font-size:clamp(36px,5vw,72px);letter-spacing:-.055em;line-height:1.08;margin:8px 0;color:var(--p-ink)}
.puzzle-heading p{max-width:330px;color:var(--p-muted);font-size:17px;line-height:1.5}.puzzle-kicker{font:700 11px/1.5 'Courier New',monospace;letter-spacing:.14em;color:var(--p-accent)}
.puzzle-tabs{display:flex;gap:8px;flex-wrap:wrap;margin:0 0 22px}.puzzle-tabs a{padding:10px 15px;border:1px solid var(--p-line);border-radius:5px;color:var(--p-ink);font-weight:700;text-decoration:none;min-height:44px}.puzzle-tabs a[aria-current=page]{background:var(--p-ink);color:var(--p-paper)}
.puzzle-layout{display:grid;grid-template-columns:minmax(0,650px) minmax(230px,1fr);gap:28px;align-items:start}.puzzle-cabinet{background:var(--p-rim);border:3px solid var(--p-shadow);border-radius:19px;padding:14px;box-shadow:0 7px 0 var(--p-shadow);color:#fff4d1;position:relative}
.puzzle-toolbar{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:2px 1px 12px}.puzzle-stamp{font:700 12px 'Courier New',monospace;letter-spacing:.12em}.puzzle-tools{display:flex;gap:5px;flex-wrap:wrap;justify-content:end}
.puzzle-tools button{font:700 12px/1.2 inherit;padding:8px 11px;border:1px solid #ffffff70;color:#fff4d1;background:#16332d60;border-radius:5px;min-height:44px;cursor:pointer}
.puzzle-hud{display:grid;grid-template-columns:1.2fr 1fr 1fr;gap:2px;background:#0d2825;color:#ffedbb;border:2px solid #0d2825;border-radius:9px 9px 0 0;overflow:hidden}.puzzle-hud>div{padding:10px 12px;background:#1b3931}.puzzle-hud span{display:block;font:700 10px 'Courier New',monospace;letter-spacing:.08em;opacity:.8}.puzzle-hud strong{font:700 clamp(22px,4vw,32px)/1.2 'Courier New',monospace;font-variant-numeric:tabular-nums}.puzzle-hud .urgent{color:#ff9275}
.puzzle-meter{height:4px;background:#102d27}.puzzle-meter i{display:block;height:100%;background:#f6c774;transition:width .25s linear}.puzzle-orders{display:flex;gap:12px;justify-content:center;align-items:center;min-height:42px;background:var(--p-paper);color:var(--p-ink);padding:5px 10px;font:700 13px 'Courier New',monospace;border-bottom:2px solid var(--p-line)}.puzzle-order{display:flex;align-items:center;gap:4px}.puzzle-order svg{width:29px;height:29px}.puzzle-orders .done{opacity:.55;text-decoration:line-through}
.puzzle-workspace{position:relative;background:var(--p-paper);padding:12px;border-radius:0 0 8px 8px;overflow:hidden}.puzzle-board{display:grid;grid-template-columns:repeat(var(--cols),minmax(0,1fr));gap:3px;background:var(--p-line);padding:4px;border:2px solid #8a7959;border-radius:8px;max-width:490px;margin:auto;touch-action:pan-y}
.puzzle-cell{padding:0;aspect-ratio:1;border:0;border-radius:4px;background:var(--p-tile);position:relative;min-width:0;color:var(--p-ink);cursor:pointer;display:grid;place-items:center;box-shadow:inset 0 1px 1px #fff8,inset 0 -2px 1px #0001;touch-action:none}.puzzle-cell svg{width:92%;height:92%;pointer-events:none;filter:drop-shadow(0 2px 1px #0002)}
.puzzle-cell.selected{outline:3px solid var(--p-accent);outline-offset:-3px;z-index:1;background:#eecb7a}.puzzle-cell.highlight{background:#eecb7a;box-shadow:inset 0 0 0 3px #9e541d}.puzzle-cell.ghost{box-shadow:inset 0 0 0 3px #568957;background:#a8c39a}.puzzle-cell.invalid{box-shadow:inset 0 0 0 3px #ce6048}.puzzle-cell.hint{outline:3px dashed var(--p-accent);outline-offset:-3px}.puzzle-cell.flash{animation:puzzle-pop .32s ease-out}.puzzle-cell.box-right{border-right:2px solid var(--p-rim)}.puzzle-cell.box-bottom{border-bottom:2px solid var(--p-rim)}
.puzzle-cell:focus-visible,.puzzle-tray button:focus-visible{outline:3px solid #d56d31;outline-offset:2px;z-index:2}.puzzle-cell:disabled{cursor:default;opacity:1}
.puzzle-hand{display:flex;gap:8px;justify-content:center;align-items:center;margin:12px 0 2px;min-height:80px}.puzzle-hand button{background:var(--p-paper);border:2px solid var(--p-line);border-radius:8px;min-width:27%;padding:10px;color:var(--p-ink);cursor:pointer;min-height:78px;position:relative}.puzzle-hand button[aria-pressed=true]{border-color:var(--p-accent);box-shadow:0 0 0 2px var(--p-accent)}.puzzle-hand button:disabled{opacity:.35}.puzzle-shape{display:grid;grid-template-columns:repeat(var(--w),16px);grid-auto-rows:16px;gap:2px;width:max-content;margin:auto}.puzzle-shape i{border-radius:3px;background:#edbf76;border:1px solid #a07142;box-shadow:inset 1px 1px 0 #fff6}.puzzle-piece-key{position:absolute;left:6px;bottom:4px;font:700 10px monospace}
.puzzle-overlay{position:absolute;inset:0;background:#17392eea;z-index:4;display:flex;align-items:center;justify-content:center;padding:20px;text-align:center;backdrop-filter:blur(7px)}.puzzle-overlay[hidden]{display:none}.puzzle-menu{max-width:380px;color:#fff0c8}.puzzle-menu h2{font:700 clamp(30px,5vw,52px)/1.02 Georgia,'Noto Serif TC',serif;letter-spacing:-.04em;margin:10px 0 15px}.puzzle-menu p{line-height:1.65;font-size:15px}.puzzle-menu .puzzle-kicker{color:#f0bb75}.puzzle-primary{background:#f6cf80;color:#283d2e;border:2px solid #d69e48;min-height:48px;padding:12px 24px;border-radius:6px;font-weight:800;cursor:pointer}.puzzle-secondary{display:block;background:transparent;color:inherit;border:1px solid currentColor;padding:10px 17px;border-radius:5px;min-height:44px;margin:10px auto;cursor:pointer}.puzzle-result-total{font:700 42px 'Courier New',monospace;margin:14px}.puzzle-status{min-height:40px;margin:12px 2px 0;font:700 12px/1.5 'Courier New',monospace}.puzzle-status strong{color:#ffda8c}.puzzle-under-controls{display:flex;gap:8px;align-items:center;justify-content:center;margin:12px 0 0;flex-wrap:wrap}.puzzle-under-controls button{min-height:44px;padding:8px 13px;background:#16332d60;color:#fff1c8;border:1px solid #ffffff70;border-radius:5px;cursor:pointer}.puzzle-sidebar{display:grid;gap:20px;color:var(--p-ink)}.puzzle-ticket{background:var(--p-paper);padding:24px;border:1px solid var(--p-line);border-top:8px solid var(--p-rim);border-radius:3px;box-shadow:3px 5px 0 #0001}.puzzle-ticket h2{font:700 27px Georgia,'Noto Serif TC',serif;margin:8px 0 16px}.puzzle-ticket p,.puzzle-ticket li{font-size:14px;line-height:1.7}.puzzle-ticket ol{padding-left:20px}.puzzle-ticket li{padding-bottom:10px}.puzzle-best{display:flex;justify-content:space-between;border-top:1px dashed var(--p-line);padding-top:14px;gap:10px}.puzzle-best strong{font:700 22px monospace}.puzzle-board-list{list-style:none;padding:0!important;margin:15px 0}.puzzle-board-list li{display:flex;justify-content:space-between;gap:8px;border-bottom:1px dashed var(--p-line);padding:8px 0;overflow-wrap:anywhere}.puzzle-board-list strong{font-variant-numeric:tabular-nums;flex-shrink:0}.puzzle-score-form{max-width:300px;margin:10px auto}.puzzle-note{font-size:12px!important;line-height:1.5!important}.puzzle-help{max-width:600px;padding:28px;background:var(--p-paper,#fff6df);color:var(--p-ink,#244c40);border:3px solid var(--p-rim,#527d67);border-radius:12px}.puzzle-help::backdrop{background:#112d2acc}.puzzle-help p{line-height:1.7}.puzzle-help button{margin-top:10px}.puzzle-beta{font-size:13px;color:var(--p-muted);margin:0 0 18px}.puzzle-cover{background:#244c40}.puzzle-page .page{max-width:1180px}.puzzle-page .game-comments{margin-top:34px}.puzzle-burst{position:absolute;inset:20% 0 auto;text-align:center;font:700 clamp(24px,5vw,45px) Georgia,serif;color:#fff3c5;text-shadow:0 3px 0 #294332,2px 0 0 #294332,-2px 0 0 #294332;pointer-events:none;z-index:3;animation:puzzle-burst .7s ease-out both}.puzzle-burst:empty{display:none}
@keyframes puzzle-pop{0%{transform:scale(.72);filter:brightness(1.5)}100%{transform:scale(1)}}@keyframes puzzle-burst{0%{opacity:0;transform:translateY(18px) scale(.8)}25%{opacity:1}100%{opacity:0;transform:translateY(-25px)}}
@media(max-width:850px){.puzzle-layout{grid-template-columns:minmax(0,1fr);max-width:650px;margin:auto}.puzzle-sidebar{grid-template-columns:repeat(2,minmax(0,1fr))}.puzzle-heading p{max-width:240px}.puzzle-ticket{padding:18px}}
@media(max-width:480px){.puzzle-page .page{padding-left:10px;padding-right:10px}.puzzle-heading{display:block;margin:18px 0}.puzzle-heading p{max-width:none;font-size:14px;margin:8px 0}.puzzle-cabinet{padding:8px;border-radius:12px}.puzzle-toolbar{padding-bottom:8px}.puzzle-stamp{font-size:10px;letter-spacing:0}.puzzle-tools button{padding:7px;min-height:44px;font-size:11px}.puzzle-workspace{padding:7px}.puzzle-board{gap:2px;padding:3px}.puzzle-sidebar{grid-template-columns:1fr}.puzzle-hud>div{padding:9px 8px}.puzzle-hud span{font-size:9px}.puzzle-menu h2{font-size:32px}.puzzle-menu p{font-size:13px;line-height:1.5}.puzzle-overlay{padding:12px}.puzzle-menu{max-width:285px}.puzzle-menu .puzzle-note{font-size:11px!important}.puzzle-tabs a{padding:10px 12px;font-size:13px}.puzzle-orders{font-size:11px;gap:8px}.puzzle-primary{padding:10px 18px}.puzzle-shape{grid-template-columns:repeat(var(--w),14px);grid-auto-rows:14px}}
@media(min-width:650px) and (max-height:550px){.puzzle-layout{grid-template-columns:minmax(330px,460px) minmax(220px,1fr);gap:20px;max-width:none}.puzzle-heading{margin:12px 0}.puzzle-heading h1{font-size:36px}.puzzle-heading p,.puzzle-beta,.puzzle-tabs{display:none}.puzzle-board{max-width:300px}.puzzle-hud>div{padding:5px 10px}.puzzle-hud strong{font-size:22px}.puzzle-workspace{padding:6px}.puzzle-toolbar{padding-bottom:6px}.puzzle-hand{min-height:62px;margin-top:6px}.puzzle-hand button{min-height:60px}.puzzle-sidebar{grid-template-columns:1fr}.puzzle-menu h2{font-size:28px}.puzzle-menu p{font-size:12px;margin:8px 0}.puzzle-menu .puzzle-note{display:none}.puzzle-overlay{padding:10px}.puzzle-status{min-height:25px;margin-top:8px}.puzzle-primary{padding:8px 14px;min-height:44px}}
@media(prefers-reduced-motion:reduce){.puzzle-cell.flash,.puzzle-burst{animation:none}.puzzle-meter i{transition:none}}

/* Keep the entire active tray and controls on short screens. */
.puzzle-cabinet{scroll-margin-top:8px}
@media(max-width:649px) and (max-height:700px){
 .puzzle-board{max-width:min(100%,calc(100dvh - 275px))}
 .puzzle-page[data-puzzle=sweep] .puzzle-board{max-width:min(100%,calc(80dvh - 155px))}
 .puzzle-hand{min-height:62px;margin-top:7px}.puzzle-hand button{min-height:60px;padding:6px}
 .puzzle-hud>div{padding:6px 8px}.puzzle-orders{min-height:34px}.puzzle-status{margin-top:8px;min-height:30px}
 .puzzle-overlay{padding:9px}.puzzle-menu h2{font-size:26px;margin:8px 0}.puzzle-menu p{font-size:12px;line-height:1.4;margin:8px 0}.puzzle-menu .puzzle-note{display:none}
 .puzzle-menu .puzzle-result-total{font-size:30px;margin:7px}.puzzle-menu .puzzle-score-form{margin:6px auto}
}
@media(min-width:650px) and (max-height:550px){
 .puzzle-layout{display:block;max-width:820px}.puzzle-cabinet{display:grid;grid-template-columns:minmax(0,1fr) 200px;gap:4px 12px;padding:9px}
 .puzzle-toolbar{grid-column:1/-1;padding:0}.puzzle-workspace{grid-column:1;grid-row:2/8;align-self:start}
 .puzzle-hud{grid-column:2;grid-row:2;grid-template-columns:1fr 1fr}.puzzle-hud>div:first-child{grid-column:1/-1}.puzzle-hud>div{padding:4px 8px}
 .puzzle-meter{grid-column:2;grid-row:3}.puzzle-orders{grid-column:2;grid-row:4;min-height:32px;font-size:11px;padding:4px}
 .puzzle-hand{grid-column:2;grid-row:5;min-height:60px;margin:0;gap:4px}.puzzle-hand button{padding:5px;min-width:30%;min-height:60px}.puzzle-shape{grid-template-columns:repeat(var(--w),10px);grid-auto-rows:10px;gap:1px}
 .puzzle-under-controls{grid-column:2;grid-row:6;margin:0;gap:4px}.puzzle-under-controls button{font-size:11px;min-height:40px;padding:6px 9px}
 .puzzle-status{grid-column:2;grid-row:7;margin:3px 0;font-size:10px;min-height:20px}
 .puzzle-board{max-width:calc(100dvh - 120px)}.puzzle-page[data-puzzle=sweep] .puzzle-board{max-width:calc(80dvh - 96px)}
 .puzzle-sidebar{grid-template-columns:1fr 1fr;margin-top:20px}.puzzle-menu .puzzle-note{display:none}.puzzle-menu h2{font-size:25px;margin:7px 0}.puzzle-menu p{font-size:11px;line-height:1.4;margin:7px 0}.puzzle-menu .puzzle-result-total{font-size:28px;margin:6px}.puzzle-score-form{margin:5px auto}.puzzle-menu .puzzle-kicker{font-size:9px}
}

.puzzle-board{--cols:7}.puzzle-page[data-puzzle=sweep] .puzzle-board{--cols:8}.puzzle-page[data-puzzle=tray] .puzzle-board{--cols:9}.puzzle-meter i{width:0%}
.puzzle-page[data-puzzle=sweep] .puzzle-meter i{transition:none}
/* Leave room for the complete rising tray on very short portrait screens. */
@media(max-width:649px) and (max-height:450px){.puzzle-page[data-puzzle=sweep] .puzzle-board{max-width:min(100%,calc(80dvh - 170px))}}
/* Announced dough stays distinct from placement previews in both themes. */
.puzzle-cell.buildup::after{content:'+';position:absolute;inset:10%;display:grid;place-items:center;border:2px dashed #945e15;border-radius:4px;color:#714b14;background:#f8d68080;font:bold 17px monospace;pointer-events:none}
.puzzle-cell.ghost.buildup::after,.puzzle-cell.invalid.buildup::after{opacity:.35}
.puzzle-challenges{display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin:16px 0;color:var(--p-ink)}
.puzzle-challenges button{min-height:44px;padding:9px 16px;border:2px solid var(--p-line);border-radius:6px;background:var(--p-paper);color:inherit;cursor:pointer;font-weight:700}
.puzzle-challenges button[aria-pressed=true]{border-color:#9d6327;background:#f4d397;color:#243a2f}.puzzle-challenges button:disabled{cursor:default;opacity:.7}
.puzzle-challenges p{flex-basis:100%;font-size:13px;margin:0}.puzzle-next-hand{display:flex;gap:12px;align-items:center;min-height:70px;padding:12px 0}
.puzzle-page[data-puzzle=tray] .puzzle-orders{font-variant-numeric:tabular-nums;font-size:12px}
/* Reserve room for four-square-tall hands on compact portrait screens. */
@media(max-width:649px) and (min-height:451px) and (max-height:700px){.puzzle-page[data-puzzle=tray] .puzzle-board{max-width:min(100%,calc(100dvh - 315px))}}
/* Keep the hand height steady as differently shaped pieces are used. */
@media(min-height:701px){.puzzle-hand,.puzzle-hand button{min-height:94px}}
@media(max-width:649px) and (min-height:451px) and (max-height:700px){.puzzle-hand,.puzzle-hand button{min-height:78px}.puzzle-hand .puzzle-shape{grid-template-columns:repeat(var(--w),12px);grid-auto-rows:12px}}
/* Chat stays available on pause/results without covering compact game controls. */
@media(max-width:900px),(max-height:700px){.puzzle-page.puzzle-playing>.im-launcher,.puzzle-page.puzzle-playing>.im-floating{display:none!important}}

#puzzle-leaderboard .player-link{min-height:44px}
