/* Picture Logic (logic.html, logicapp.js), on top of style.css: the slide puzzle's one-screen layout
   (.slide-app: head, status, stage, actions; More panel; level pills), so it never scrolls. The board
   is the clue column, the clue row and the grid, sized from the stage (a size container), with thicker
   lines every 5 squares. Filled squares are ink on cream (light) or cream on evergreen (dark); the
   picture's own colours show only once it's solved. As the approved mockups (previews/games/picture-logic). */
:root {
  --pl-cell: var(--card); --pl-thin: var(--line); --pl-five: color-mix(in srgb, var(--ink) 45%, transparent);
  --pl-fill: var(--pw-ink); --pl-x: var(--muted); --pl-clue: var(--ink); --pl-clue-met: color-mix(in srgb, var(--muted) 55%, transparent);
  --pl-line: color-mix(in srgb, var(--accent) 22%, var(--card)); --pl-wrong: var(--secondary);
}
:root[data-theme="dark"] {
  --pl-cell: var(--pw-evergreen-deep); --pl-thin: color-mix(in srgb, var(--pw-cream) 14%, transparent);
  --pl-five: color-mix(in srgb, var(--pw-cream) 45%, transparent);
  --pl-fill: var(--pw-cream); --pl-x: color-mix(in srgb, var(--pw-cream) 55%, transparent); --pl-clue: var(--pw-cream);
  --pl-clue-met: color-mix(in srgb, var(--pw-cream) 30%, transparent);
  --pl-line: color-mix(in srgb, var(--pw-evergreen) 75%, var(--pw-evergreen-deep)); --pl-wrong: #E2707C;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --pl-cell: var(--pw-evergreen-deep); --pl-thin: color-mix(in srgb, var(--pw-cream) 14%, transparent);
  --pl-five: color-mix(in srgb, var(--pw-cream) 45%, transparent);
  --pl-fill: var(--pw-cream); --pl-x: color-mix(in srgb, var(--pw-cream) 55%, transparent); --pl-clue: var(--pw-cream);
  --pl-clue-met: color-mix(in srgb, var(--pw-cream) 30%, transparent);
  --pl-line: color-mix(in srgb, var(--pw-evergreen) 75%, var(--pw-evergreen-deep)); --pl-wrong: #E2707C;
} }

.pl-app [hidden] { display: none !important; }
.pl-app .levels { align-items: center; }
.pl-app .levels .btn { padding: 10px 12px; }
.pl-status .count span:first-child { color: var(--primary); }
.pl-gallery-head { margin: 12px 0 6px; color: var(--muted); font-size: 14px; }
.pl-gallery { display: flex; flex-wrap: wrap; gap: 6px; }
.pl-gallery .btn { min-height: 38px; padding: 6px 12px; font-size: 14px; }

/* the board: clues + grid, the largest square that fits (--cw / --ch: the clue areas, in squares) */
.pl-board { --n: 10; --cw: 2.6; --ch: 2.6;
  --cell: min(100cqw / (var(--n) + var(--cw)), 100cqh / (var(--n) + var(--ch)), 64px);
  display: grid; grid-template-columns: calc(var(--cell) * var(--cw)) calc(var(--cell) * var(--n));
  grid-template-rows: calc(var(--cell) * var(--ch)) calc(var(--cell) * var(--n));
  outline: none; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
.pl-corner { display: grid; place-items: center; }
.pl-cols { display: grid; grid-template-columns: repeat(var(--n), 1fr); align-items: end; }
.pl-rows { display: grid; grid-template-rows: repeat(var(--n), 1fr); }
.pl-clue { display: flex; gap: calc(var(--cell) * .18); color: var(--pl-clue); font: 600 calc(var(--cell) * .5)/1 Inter, system-ui, sans-serif;
  font-variant-numeric: tabular-nums; transition: color .3s; }
.pl-cols .pl-clue { flex-direction: column; align-items: center; justify-content: flex-end; padding-bottom: calc(var(--cell) * .18); height: 100%; }
.pl-rows .pl-clue { justify-content: flex-end; align-items: center; padding-right: calc(var(--cell) * .25); }
.pl-clue.met { color: var(--pl-clue-met); }
.pl-clue.on { background: var(--pl-line); border-radius: 6px; }
.pl-grid { display: grid; grid-template-columns: repeat(var(--n), 1fr); grid-template-rows: repeat(var(--n), 1fr); position: relative;
  background: var(--pl-cell); border: 2.5px solid var(--pl-five); border-radius: 6px; overflow: hidden; touch-action: none; }
.pl-c { position: relative; border-right: 1px solid var(--pl-thin); border-bottom: 1px solid var(--pl-thin); transition: background-color .5s; }
.pl-c.r5 { border-right: 2px solid var(--pl-five); }
.pl-c.b5 { border-bottom: 2px solid var(--pl-five); }
.pl-c.lc { border-right: 0; }
.pl-c.lr { border-bottom: 0; }
.pl-c.line { background: var(--pl-line); }
.pl-c.f { background: var(--pl-fill); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--pl-cell) 40%, transparent); }
.pl-c.x::before, .pl-c.x::after { content: ""; position: absolute; left: 50%; top: 50%; width: 52%; height: 2px; border-radius: 1px; background: var(--pl-x); }
.pl-c.x::before { transform: translate(-50%, -50%) rotate(45deg); }
.pl-c.x::after { transform: translate(-50%, -50%) rotate(-45deg); }
.pl-c.drag { background: color-mix(in srgb, var(--pl-fill) 45%, var(--pl-cell)); }
.pl-c.wrong { box-shadow: inset 0 0 0 3px var(--pl-wrong); z-index: 1; }
.pl-c.hinted { box-shadow: inset 0 0 0 3px var(--accent); z-index: 1; animation: pulse 1.2s ease-in-out 2; }
.pl-c.cur { box-shadow: inset 0 0 0 3px var(--focus); z-index: 2; }
body.tv .pl-c.cur { box-shadow: inset 0 0 0 3px var(--pw-cream), inset 0 0 0 6px var(--focus); }
body.keys .pl-board:focus .pl-grid { border-color: var(--focus); }
/* solved: the squares take the picture's colours (set by the page), the lines melt away */
.pl-grid.solved { background: var(--pw-cream); border-color: var(--pw-honey);
  box-shadow: 0 0 0 4px var(--pw-honey), 0 0 28px 6px color-mix(in srgb, var(--pw-honey) 55%, transparent); animation: glow 1.6s ease-in-out 2; }
.pl-grid.solved .pl-c { border-color: transparent; box-shadow: none; }
.pl-grid.solved .pl-c::before, .pl-grid.solved .pl-c::after { display: none; }
.pl-note { position: absolute; left: 50%; top: 4px; transform: translateX(-50%); z-index: 6; margin: 0; padding: 8px 14px; border-radius: 18px;
  max-width: calc(100% - 16px); width: max-content; text-align: center; background: var(--surface); color: var(--ink);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .3); font-size: 14px; pointer-events: none; }

/* the tools: Fill / Mark, Undo, Hint, Check */
.pl-actions { flex-direction: column; align-items: stretch; flex-wrap: nowrap; gap: 8px; }
.pl-tools { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.pl-seg { display: inline-flex; border: 1px solid var(--muted); border-radius: 999px; padding: 3px; gap: 2px; flex: none; }
.pl-seg button { display: inline-flex; align-items: center; gap: 8px; border: 0; min-height: 44px; padding: 8px 14px; border-radius: 999px; background: transparent;
  color: var(--ink); font: 600 15px/1 Inter, system-ui, sans-serif; cursor: pointer; touch-action: manipulation; }
.pl-seg button[aria-pressed="true"] { background: var(--btn-bg); color: var(--btn-ink); }
.pl-seg .sw { width: 15px; height: 15px; border-radius: 3px; background: currentColor; }
.pl-seg .xx { font: 700 17px/1 Inter, sans-serif; }
.pl-tool { flex: 1; min-width: 0; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 4px 0; background: transparent; border: 0; border-radius: 14px; color: var(--ink); font: 500 12px/1 Inter, system-ui, sans-serif;
  cursor: pointer; touch-action: manipulation; }
.pl-tool svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
body.keys .pl-app .pl-tool:focus, body.keys .pl-app .pl-seg button:focus { outline: 3px solid var(--focus); outline-offset: 2px; }
.pl-legend { display: none; }
.pl-actions.over > .pl-tools, .pl-actions.over > .pl-legend { display: none; }
.pl-done { position: static; margin: 0; padding: 14px 18px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); max-width: none; }
.pl-done-head { gap: 12px; }
.pl-done h2 { margin: 0; font-size: 26px; }
.pl-done p { margin: 4px 0 0; }
.pl-art { flex: none; width: 64px; height: 64px; border-radius: 12px; background: var(--pw-cream) center / 84% no-repeat; box-shadow: inset 0 0 0 1px var(--line); }
.pl-art-pip, .pl-art-wick, .pl-art-wick-asleep { box-sizing: border-box; border: solid var(--pw-cream); border-width: 6px 12px;
  background-size: 800% 900%; background-position: 0 0; background-repeat: no-repeat; box-shadow: 0 0 0 1px var(--line); }   /* frame 0 of the idle sheet */
.pl-art-pip { background-image: url("/play/assets/mascot/256/pip-idle-cutout.sheet.png"); }
.pl-art-wick { background-image: url("/play/assets/mascot/256/wick-idle-cutout.sheet.png"); }
.pl-art-wick-asleep { background-image: url("/play/assets/mascot/256/wick-asleep-cutout.sheet.png"); }
.pl-art-none { display: none; }
.pl-done-actions { margin: 12px 0 0; display: flex; gap: 8px; flex-wrap: wrap; }
.pl-done-actions .btn { text-decoration: none; display: inline-flex; align-items: center; }

/* How to play: a card over the game; the little board plays the worked example */
.pl-howto { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px;
  background: color-mix(in srgb, var(--pw-ink) 45%, transparent); }
.pl-howto[hidden] { display: none; }
.pl-howto-card { width: min(400px, 100%); max-height: calc(100dvh - 32px); overflow: auto; overscroll-behavior: contain; box-sizing: border-box;
  padding: 18px 18px 16px; border-radius: 20px; background: var(--surface); color: var(--ink); box-shadow: 0 18px 50px rgba(0, 0, 0, .35); }
.pl-howto h2 { margin: 0 0 10px; font: 500 24px/1.2 Fraunces, Georgia, serif; color: var(--primary); }
.pl-howto-body { display: flex; flex-direction: column; gap: 12px; }
.pl-howto-demo { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pl-demo { --q: 26px; display: grid; grid-template-columns: calc(var(--q) * 1.3) repeat(5, var(--q)); grid-auto-rows: var(--q);
  font: 600 13px/1 Inter, system-ui, sans-serif; color: var(--pl-clue); }
.pl-demo > span:first-child { grid-row: 1; }
.pl-dc { display: grid; place-items: center; border-radius: 5px; transition: background-color .25s; }
.pl-dc-row { justify-items: end; padding-right: 6px; }
.pl-dc.on { background: var(--pl-line); }
.pl-dq { position: relative; background: var(--pl-cell); border: 1px solid var(--pl-thin); margin: 0 -1px -1px 0; transition: background-color .35s; }
.pl-dq.f { background: var(--pl-fill); }
.pl-dq.x::before, .pl-dq.x::after { content: ""; position: absolute; left: 50%; top: 50%; width: 52%; height: 2px; background: var(--pl-x); }
.pl-dq.x::before { transform: translate(-50%, -50%) rotate(45deg); }
.pl-dq.x::after { transform: translate(-50%, -50%) rotate(-45deg); }
.pl-demo.done .pl-dq { border-color: transparent; }
.pl-demo-say { margin: 0; min-height: 2.6em; text-align: center; font-size: 14px; line-height: 1.3; color: var(--ink); }
.pl-howto-points { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 6px; font-size: 15px; line-height: 1.4; }
.pl-strip { display: inline-flex; align-items: center; gap: 2px; vertical-align: middle; margin: 0 4px; }
.pl-strip i { font: 600 13px/1 Inter, system-ui, sans-serif; font-style: normal; margin-right: 4px; color: var(--pl-clue); }
.pl-strip s { width: 14px; height: 14px; border: 1px solid var(--pl-thin); background: var(--pl-cell); text-decoration: none; }
.pl-strip s.f { background: var(--pl-fill); }
.pl-howto-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
body.keys .pl-howto .btn:focus { outline: 3px solid var(--focus); outline-offset: 3px; }

@media (orientation: landscape) and (min-aspect-ratio: 5/4) {
  .pl-tools { flex-wrap: wrap; }
  .pl-howto-card { width: min(640px, 100%); }
  .pl-howto-body { flex-direction: row; align-items: center; }
  .pl-howto-demo { flex: none; }
}
@media (orientation: landscape) and (min-aspect-ratio: 5/4) and (max-height: 500px) {
  .pl-app .slide-status .count { font-size: 18px; }
  .pl-app .levels .btn { min-height: 34px; padding: 6px 9px; font-size: 13px; }
  .pl-seg button { min-height: 34px; padding: 6px 10px; font-size: 13px; }
  .pl-tool { min-height: 40px; font-size: 11px; }
  .pl-tool svg { width: 20px; height: 20px; }
  .pl-done { padding: 8px 12px; }
  .pl-done h2 { font-size: 21px; }
  .pl-done p { font-size: 14px; line-height: 1.3; margin-top: 0; }
  .pl-art { width: 44px; height: 44px; }
  .pl-done-actions { margin-top: 8px; gap: 6px; }
  .pl-done-actions .btn { min-height: 36px; padding: 6px 11px; font-size: 13px; white-space: nowrap; }
}
/* TV (body.tv, from the app's tvplay.js): sized in vh so 1920x1080 and Fire TV's 960x540 look the same, and the
   side column's type big enough to read from the sofa (at 960x540 nothing under about 12 px);
   the safe area is style.css's margin, so no padding on top of it */
body.tv .pl-app.slide-app { padding: 0; }
body.tv .pl-app { grid-template: "stage head" auto "stage status" auto "stage actions" minmax(0, 1fr) / minmax(0, 1fr) 30vw;
                  column-gap: 2.4vw; row-gap: 1.6vh; }
body.tv .pl-board { --cell: min(100cqw / (var(--n) + var(--cw)), 100cqh / (var(--n) + var(--ch))); }
body.tv .pl-clue { font-size: max(calc(var(--cell) * .5), 2.3vh); }   /* the TV text rule: 12 px at 960x540, even at 20x20 */
body.tv .pl-app .slide-head .brand { font-size: 2.3vh; padding: .4vh 0; }
body.tv .pl-app .slide-head h1 { font-size: 4.6vh; }
body.tv .pl-app .more summary { font-size: 2.3vh; min-height: 5.4vh; min-width: 0; padding: 1vh 2vh; }
body.tv .pl-app .count, body.tv .pl-app .clock { font-size: 3.6vh; }
body.tv .pl-app .levels { gap: 1vh; }
body.tv .pl-app .levels .btn { font-size: 2.4vh; padding: 1.1vh 1.6vh; min-height: 5.8vh; min-width: 0; }
body.tv .pl-tools { flex-wrap: wrap; gap: 1.1vh; }
body.tv .pl-seg { flex: 1 1 100%; justify-content: center; }
body.tv .pl-seg button { flex: 1; justify-content: center; font-size: 2.6vh; min-height: 6.4vh; padding: 1vh 2vh; }
body.tv .pl-seg .xx { font-size: 1.1em; }
body.tv .pl-seg .sw { width: .85em; height: .85em; }
body.tv .pl-tool { min-height: 9vh; font-size: 2.3vh; gap: .7vh; border-radius: 1.4vh; background: var(--card); }
body.tv .pl-tool svg { width: 3.6vh; height: 3.6vh; }
body.tv .pl-app .pl-tool:focus, body.tv .pl-app .pl-seg button:focus { background: var(--focus); color: var(--on-focus); outline: 4px solid var(--focus); outline-offset: 3px; }
body.tv .pl-legend { display: block; margin: 0; color: var(--muted); font-size: 2.3vh; line-height: 1.7; }
body.tv .pl-legend kbd { display: inline-block; min-width: 2.2em; text-align: center; font: 600 2.3vh/1 Inter, sans-serif; padding: .6vh .8vh;
  border-radius: .7vh; background: var(--card); color: var(--ink); margin-right: .7vh; }
body.tv .pl-note { font-size: 2.3vh; padding: 1vh 1.8vh; }
body.tv .pl-done { padding: 1.8vh 2.2vh; }
body.tv .pl-done h2 { font-size: 3.6vh; }
body.tv .pl-done p { font-size: 2.4vh; }
body.tv .pl-art { width: 9vh; height: 9vh; }
body.tv .pl-done-actions { gap: .8vh; margin-top: 1.2vh; }
body.tv .pl-done-actions .btn { font-size: 2.3vh; min-height: 5.8vh; padding: 1vh 2vh; }
body.tv .pl-howto-card { width: min(110vh, 90vw); padding: 3vh 3.4vh; border-radius: 2.4vh; }
body.tv .pl-howto h2 { font-size: 4.2vh; margin-bottom: 2vh; }
body.tv .pl-howto-body { gap: 3vh; }
body.tv .pl-demo { --q: 5.4vh; font-size: 2.4vh; }
body.tv .pl-demo-say { font-size: 2.6vh; }
body.tv .pl-howto-points { font-size: 2.6vh; gap: 1.2vh; }
body.tv .pl-strip i { font-size: 2.4vh; }
body.tv .pl-strip s { width: 2.6vh; height: 2.6vh; }
body.tv .pl-howto-actions { gap: 1.4vh; margin-top: 3vh; }
body.tv .pl-howto .btn { font-size: 2.6vh; min-height: 6.4vh; padding: 1vh 2.6vh; }
body.tv .pl-howto .btn:focus { background: var(--focus); border-color: var(--focus); color: var(--on-focus); outline: 4px solid var(--focus); outline-offset: 4px; }
@media (prefers-reduced-motion: reduce) {
  .pl-c, .pl-clue { transition: none; }
  .pl-c.hinted, .pl-grid.solved { animation: none; }
}
