.puzzle-home{margin:14px 0}.puzzle-dialog{width:min(450px,96vw);max-height:94dvh;overflow-y:auto}.puzzle-stages{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;margin:12px 0}.puzzle-stages button{padding:10px 3px;font-size:12px;min-height:46px}.puzzle-stages button[aria-pressed=true]{border-color:#62ecd2;background:#163832}.puzzle-board{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:repeat(3,minmax(0,1fr));gap:3px;aspect-ratio:5/7;border:4px solid #070c14;border-radius:12px;overflow:hidden;background:#070c14}.puzzle-piece{min-width:0;min-height:0;border:0;border-radius:3px;padding:0;background-size:300% 300%;background-repeat:no-repeat;position:relative;touch-action:manipulation}.puzzle-piece[aria-pressed=true]{outline:4px solid white;outline-offset:-4px;z-index:1}.puzzle-piece.correct::after{content:'';position:absolute;bottom:5px;right:5px;width:6px;height:6px;border-radius:50%;background:#65f2d4;box-shadow:0 0 0 2px #15352d}.puzzle-piece:disabled{opacity:1}.puzzle-dialog img{display:block;max-width:100%;max-height:72dvh;object-fit:contain;margin:auto}.puzzle-success{border:1px solid #347267;border-radius:12px;background:#12382d;color:#80f1d4;padding:12px}.puzzle-dialog>button{width:100%;margin:7px 0}

/* Preserve the original single-column flow outside landscape. */
.puzzle-layout,.puzzle-game,.puzzle-controls{display:contents}
.puzzle-controls>button{width:100%;margin:7px 0}

@media(orientation:landscape) and (min-width:600px){
 .puzzle-dialog.puzzle-game-dialog[open]:modal,
 body.soft-velvet .puzzle-dialog.puzzle-game-dialog[open]:modal{
  position:fixed;
  top:calc(var(--sv-safe-top,0px) + 12px);bottom:calc(var(--sv-safe-bottom,0px) + 12px);
  left:calc(var(--sv-safe-left,0px) + 12px);right:calc(var(--sv-safe-right,0px) + 12px);
  display:grid;grid-template-rows:auto minmax(0,1fr);gap:12px;margin:auto;
  box-sizing:border-box;width:calc(100vw - var(--sv-safe-left,0px) - var(--sv-safe-right,0px) - 24px);
  max-width:1020px;height:min(820px,calc(100dvh - var(--sv-safe-top,0px) - var(--sv-safe-bottom,0px) - 24px));
  max-height:calc(100dvh - var(--sv-safe-top,0px) - var(--sv-safe-bottom,0px) - 24px);
  padding:16px;overflow:hidden;overscroll-behavior:contain;
 }
 .puzzle-game-dialog>.heading{margin:0;min-width:0}
 .puzzle-layout{display:grid;grid-template-columns:minmax(0,1fr) minmax(240px,36%);gap:24px;min-width:0;min-height:0}
 .puzzle-game{display:grid;place-items:center;min-width:0;min-height:0;overflow:hidden}
 .puzzle-controls{display:flex;flex-direction:column;justify-content:flex-start;justify-content:safe center;gap:12px;min-width:0;min-height:0;overflow-y:auto;overscroll-behavior:contain}
 .puzzle-controls>*{flex:0 0 auto;margin:0}
 .puzzle-controls>.puzzle-stages{margin:0;gap:6px}
 .puzzle-controls .puzzle-stages button{min-height:44px;padding:8px 4px;font-size:12px}
 .puzzle-controls>button{margin:0;min-height:44px}
 .puzzle-controls>.panel-note{margin:0;font-size:13px;line-height:1.5}
 .puzzle-controls>.panel-note:empty{display:none}
 .puzzle-controls>.puzzle-success{margin:0;padding:10px;font-size:13px}
 .puzzle-stage-complete .puzzle-help{display:none}
 .puzzle-game .puzzle-board{margin:0;max-width:100%;max-height:100%}
 .puzzle-dialog.puzzle-sample-dialog[open]:modal,
 body.soft-velvet .puzzle-dialog.puzzle-sample-dialog[open]:modal{
  display:grid;grid-template-rows:auto minmax(0,1fr);gap:10px;box-sizing:border-box;
  position:fixed;top:calc(var(--sv-safe-top,0px) + 12px);bottom:calc(var(--sv-safe-bottom,0px) + 12px);
  left:calc(var(--sv-safe-left,0px) + 12px);right:calc(var(--sv-safe-right,0px) + 12px);margin:auto;
  width:calc(100vw - var(--sv-safe-left,0px) - var(--sv-safe-right,0px) - 24px);max-width:620px;
  height:min(820px,calc(100dvh - var(--sv-safe-top,0px) - var(--sv-safe-bottom,0px) - 24px));
  max-height:calc(100dvh - var(--sv-safe-top,0px) - var(--sv-safe-bottom,0px) - 24px);overflow:hidden;
 }
 .puzzle-sample-dialog>.heading{margin:0;min-width:0}
 .puzzle-sample-dialog>img{min-height:0;min-width:0;width:100%;height:100%;max-height:100%;object-fit:contain;margin:0}
}
@media(orientation:landscape) and (max-height:480px) and (min-width:600px){
 .puzzle-dialog.puzzle-game-dialog[open]:modal,
 body.soft-velvet .puzzle-dialog.puzzle-game-dialog[open]:modal{padding:10px;gap:8px}
 .puzzle-layout{grid-template-columns:minmax(0,1fr) minmax(270px,45%);gap:12px}
 .puzzle-controls{gap:8px;justify-content:flex-start}
 .puzzle-game-dialog>.heading h2{font-size:18px}
 .puzzle-game-dialog>.heading .icon-button{width:36px;height:36px;flex-basis:36px;min-height:36px}
}
