/* BimiPlay 6.7.0 — game playability/stability fixes only. */

/* Keep interactive boards steady while a round changes. */
#game-stage{box-sizing:border-box;contain:layout paint;}
#game-stage button{touch-action:manipulation;}
#game-stage .choice,#game-stage .sort-btn,#game-stage .letter-tile,#game-stage .shape-piece,#game-stage .shape-target,#game-stage .simon-btn{min-height:46px;}

/* Odd-one-out arrows: fixed box prevents glyph/rotation from changing row height. */
.direction-arrow{display:inline-grid;place-items:center;width:64px;height:64px;font-size:50px;line-height:1;transform-origin:center;}

/* Count games: make the four variants visually and spatially distinct. */
.count-game{width:min(620px,100%);}
.count-board{box-sizing:border-box;}
.count-board.count-shapes .shape-dot{width:52px;height:52px;}
.count-board.count-stars{font-size:46px;line-height:1.1;}
.count-board.count-groups{gap:14px;align-items:center;}
.count-group{display:inline-flex;flex-wrap:wrap;justify-content:center;align-items:center;gap:4px;width:86px;min-height:58px;padding:7px;border:2px solid #dbe8e3;border-radius:16px;background:#f8fbfa;box-sizing:border-box;}
.count-group .shape-dot{width:18px;height:18px;}

/* Shape matching / mini tangram: matched pieces keep their cell, so nothing reflows. */
.shape-match{width:min(680px,100%);grid-template-columns:minmax(0,1fr) minmax(0,1fr)!important;gap:18px;align-items:start;min-height:340px;}
.shape-panel{min-width:0;display:grid;grid-template-rows:auto 1fr;gap:8px;}
.shape-panel-label{display:block;text-align:center;font-size:14px;font-weight:850;color:#557078;letter-spacing:.02em;}
.shape-bank,.shape-targets{min-width:0;align-content:start;grid-auto-rows:minmax(82px,1fr);gap:10px;}
.shape-piece,.shape-target{box-sizing:border-box;min-width:0;min-height:82px!important;aspect-ratio:1;border-radius:18px;overflow:visible;}
.shape-piece.matched{visibility:hidden;pointer-events:none;}
.shape-piece.selected{outline:4px solid #2bb7a9;outline-offset:1px;}
.shape-target.filled{background:#e5f7f3;}
.shape-target.bad{outline:4px solid #d95f78;outline-offset:1px;}
.shape-symbol{display:inline-grid;place-items:center;width:74%;height:74%;}
.match-glyph{transform:rotate(var(--piece-rot,0deg)) scale(var(--piece-scale,1));transform-origin:50% 50%;transition:transform .12s ease;}
.shape-target .target-symbol{opacity:.24;filter:saturate(.2);}
.shape-target.filled .shape-symbol{opacity:1;filter:none;}
.shape-parallelogram{border-radius:4px!important;clip-path:polygon(22% 0,100% 0,78% 100%,0 100%);}
.game-match-tangram .shape-piece,.game-match-tangram .shape-target{background:#fff;}

/* Simon: symbols remain readable on colored buttons and board size is stable. */
.simon-grid{width:min(430px,100%);}
.simon-btn{display:grid;place-items:center;position:relative;overflow:hidden;}
.simon-btn span{font-size:clamp(26px,6vw,44px);font-weight:950;color:#17313a;text-shadow:0 1px 0 rgba(255,255,255,.8);pointer-events:none;}
.simon-btn.lit{box-shadow:0 0 0 5px #fff,0 0 0 8px #17313a;}

/* Sudoku symbols: consistent scale for digits and shapes. */
.sudoku-cell{overflow:hidden;}
.sudoku-cell .shape-dot{width:32px;height:32px;max-width:70%;max-height:70%;}
.sudoku-cell.blank{min-height:52px;}

/* Visual part-whole model for number bonds. */
.number-bond-game{width:min(560px,100%);text-align:center;}
.bond-model{display:grid;grid-template-columns:1fr 72px 1fr;grid-template-areas:"whole line line" "part1 line part2";gap:12px;align-items:center;justify-items:center;width:min(430px,100%);margin:18px auto 20px;}
.bond-whole,.bond-part{display:grid;place-items:center;width:92px;height:72px;border:3px solid #2bb7a9;border-radius:22px;background:#fff;font-size:30px;font-weight:900;color:#17313a;box-sizing:border-box;}
.bond-whole{grid-area:whole;justify-self:end;}
.bond-line{grid-area:line;align-self:stretch;width:100%;min-height:72px;position:relative;}
.bond-line::before,.bond-line::after{content:"";position:absolute;background:#b8d9d2;height:3px;transform-origin:left center;left:8px;top:50%;width:80%;}
.bond-line::before{transform:rotate(28deg);}
.bond-line::after{transform:rotate(-28deg);}
.bond-part:first-of-type{grid-area:part1;}
.bond-part:last-of-type{grid-area:part2;}
.bond-part.missing{border-style:dashed;background:#fff7d8;}

/* Word/typing tasks: long words must not force horizontal scrolling. */
.word-build,.typing-game{width:min(680px,100%);text-align:center;min-width:0;}
.word-model,.typing-model,.word-answer{overflow-wrap:anywhere;word-break:break-word;max-width:100%;}
.word-build.long-word .word-model,.typing-game.long-word .typing-model{font-size:clamp(23px,6vw,40px);letter-spacing:.025em;}
.word-build.long-word .letter-bank{gap:6px;}
.word-build.long-word .letter-tile{min-width:46px;width:auto;padding:0 12px;}
.letter-tile.bad{outline:4px solid #d95f78;outline-offset:1px;}
.typing-input{max-width:100%;box-sizing:border-box;}

/* Slide puzzle feedback. */
.slide-puzzle-wrap{width:min(540px,100%);text-align:center;}
.slide-moves{margin:0 0 10px;font-size:14px;font-weight:800;color:#557078;min-height:20px;}

/* Coloring: finger-sized palette; SVG remains inside its viewBox. */
.paint-part{touch-action:manipulation;}
.color-swatch,.palette button{min-width:46px!important;min-height:46px!important;width:46px;height:46px;}
.coloring-svg{display:block;max-width:100%;height:auto;overflow:hidden;}

/* Spot the difference: 5x5 expert boards become tap-friendly on phones. */
.difference-cell{min-width:0;min-height:0;}
.difference-cell.good{outline-color:#2bb7a9;}
.difference-cell.bad{outline-color:#d95f78;}

@media (max-width:700px){
  #game-stage{padding-left:12px;padding-right:12px;}
  .shape-match{gap:8px!important;min-height:350px!important;}
  .shape-bank,.shape-targets{grid-template-columns:repeat(2,minmax(0,1fr))!important;grid-auto-rows:minmax(72px,1fr);gap:7px;}
  .shape-piece,.shape-target{min-height:72px!important;border-radius:15px;}
  .shape-symbol{width:70%;height:70%;}
  .bond-model{grid-template-columns:1fr 52px 1fr;gap:8px;}
  .bond-whole,.bond-part{width:78px;height:62px;font-size:26px;border-radius:18px;}
}

@media (max-width:520px){
  .game-theme-context{display:none!important;}
  .difference-pair{grid-template-columns:1fr!important;width:min(330px,100%);margin:10px auto;gap:10px!important;min-height:0!important;}
  .difference-grid{width:100%;box-sizing:border-box;padding:7px!important;gap:4px!important;}
  .difference-cell{border-radius:10px;min-height:46px;}
  .difference-cell .shape-dot{width:min(40px,10vw);height:min(40px,10vw);}
  .difference-theme-icon{width:min(46px,11vw);height:min(46px,11vw);}
  .count-board{padding:16px;gap:8px;}
  .count-board.count-shapes .shape-dot{width:44px;height:44px;}
  .count-board.count-stars{font-size:39px;}
  .count-group{width:72px;min-height:52px;padding:5px;}
  .shape-match{width:100%;}
  .shape-piece,.shape-target{min-height:68px!important;}
  .letter-bank{gap:7px;}
  .letter-tile{min-width:48px;height:50px;font-size:24px;}
  .word-build.long-word .letter-tile{min-width:42px;height:46px;padding:0 9px;font-size:22px;}
}

@media (max-width:390px){
  .shape-piece,.shape-target{min-height:64px!important;}
  .difference-cell{min-height:44px;}
  .bond-model{grid-template-columns:1fr 40px 1fr;}
  .bond-whole,.bond-part{width:70px;height:58px;font-size:24px;}
}

/* Keyboard tasks: mobile controls meet a comfortable touch target. */
.typing-input,.typing-check{min-height:46px;}
.typing-check{min-width:96px;}

/* Symmetry expert mode: long strips must fit inside two-column answer cards. */
@media (max-width:520px){
  .symmetry-choices .symmetry-strip{gap:3px;padding:5px;max-width:100%;box-sizing:border-box;}
  .symmetry-choices .symmetry-strip i{width:18px;height:22px;border-radius:6px;flex:0 1 18px;}
}
@media (max-width:390px){
  .symmetry-choices .symmetry-strip i{width:16px;flex-basis:16px;}
}

/* Number bonds: explicit three-row part-whole diagram (whole → two parts). */
.bond-model{grid-template-columns:1fr 1fr!important;grid-template-rows:auto 34px auto!important;grid-template-areas:none!important;column-gap:42px!important;row-gap:2px!important;position:relative;}
.bond-model>.bond-whole{grid-column:1/3!important;grid-row:1!important;justify-self:center!important;}
.bond-model>.bond-line{grid-row:2!important;align-self:stretch!important;width:100%!important;min-height:34px!important;position:relative!important;background:none!important;}
.bond-model>.bond-line::before,.bond-model>.bond-line::after{display:none!important;}
.bond-model>.bond-line.left{grid-column:1!important;border-top:3px solid #b8d9d2;transform:skewY(-17deg);transform-origin:right top;}
.bond-model>.bond-line.right{grid-column:2!important;border-top:3px solid #b8d9d2;transform:skewY(17deg);transform-origin:left top;}
.bond-model>.bond-part:not(.missing){grid-column:1!important;grid-row:3!important;justify-self:end;}
.bond-model>.bond-part.missing{grid-column:2!important;grid-row:3!important;justify-self:start;}
