/* Game surfaces: keep mechanics and animated playfield coordinates intact. */
body:not(.is-study-home){background:var(--study-bg,#f5f7fb)}
body:not(.is-study-home) #app{max-width:960px;border:0}
body:not(.is-study-home) .bg{background:linear-gradient(180deg,#edf4fb,#f7fafc)}
#game{font-family:var(--study-font,"Source Han Sans SC",sans-serif);color:var(--study-ink,#182c44)}
#game .gbar{flex-shrink:0;gap:8px;padding:calc(8px + env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) 8px max(12px,env(safe-area-inset-left));background:#fff;border-bottom:1px solid #dce5ed}
#game .gtitle{gap:8px}
#game .gname{line-height:1.4}
#game .gno{border-radius:8px;box-shadow:none;background:var(--study-teal,#16766f);font-family:"Manrope Variable",sans-serif}
#game .icon-btn{border-radius:12px;border:1px solid #d5e1eb;box-shadow:0 2px 0 #dce5ed;color:#314d69}
#game .pill{box-shadow:none;border-radius:10px;background:#f1f5f9;font-variant-numeric:tabular-nums}
#game .pill.score{color:#8a5100;background:#fff3d7}
#game .game-scope{background:#f7fafc;padding:6px max(14px,env(safe-area-inset-right)) 6px max(14px,env(safe-area-inset-left));color:#50667e;font-size:12px;line-height:1.5;max-height:64px;overflow-y:auto;overscroll-behavior:contain}
#game .tbar{flex-shrink:0;height:8px;margin:6px 14px}
#game .stage{padding-left:max(12px,env(safe-area-inset-left));padding-right:max(12px,env(safe-area-inset-right));padding-bottom:max(14px,env(safe-area-inset-bottom));scroll-padding:12px 0 max(24px,env(safe-area-inset-bottom))}
#game .stage.scroll{scrollbar-width:thin}
#game .stage.scroll>.duel,#game .stage.scroll>.conn{flex:1 0 auto;min-height:min-content}
#game :is(.card,.opts,.row,.center,.msg,.sub,.mid,.big){min-width:0;max-width:100%}
#game :is(.msg,.sub,.mid,.big){overflow-wrap:anywhere}
#game .msg{line-height:1.5}
#game .btn.sm{min-height:44px}
#game .opt{line-height:1.45;min-height:60px}
#game .opts{grid-template-columns:repeat(2,minmax(0,1fr))}
#game .opts.one{grid-template-columns:minmax(0,1fr)}
#game .kbd .k{min-height:48px;font-size:19px;min-width:0;touch-action:manipulation}
#game .kbd .k.kfn{font-size:17px}
#game :is(button,[role="button"]):focus-visible{outline:3px solid #2867ad;outline-offset:3px}
#game .conn{gap:clamp(24px,7vw,64px)}
#game .conn .col{min-width:0}
#game .node{min-height:56px;line-height:1.4}
#game .duel .half .opts{grid-template-columns:minmax(0,1fr)}
#game .duel .half .opt{min-height:52px;font-size:16px;line-height:1.4}
#game .half .hn{gap:6px;flex-wrap:wrap}
#game .buzz{flex-shrink:0;min-height:76px;font-size:24px}
#game .car{max-width:100%;height:auto;min-height:52px;overflow-wrap:anywhere;line-height:1.4}
/* The chess board was sized from clientWidth including stage padding. Scale the
   DOM grid as a square, so small screens and rotation preserve all 81 targets. */
#stage[data-game="g20"]{--board-size:min(460px,calc(100vw - 32px - env(safe-area-inset-left) - env(safe-area-inset-right)))}
#stage[data-game="g20"] .board-wrap{min-height:var(--board-size)!important}
#stage[data-game="g20"] #bd{width:var(--board-size);max-width:100%;aspect-ratio:1;grid-template-columns:repeat(9,minmax(0,1fr))!important;grid-template-rows:repeat(9,minmax(0,1fr));grid-auto-rows:auto!important}
#stage[data-game="g20"] .cell{width:100%!important;height:100%!important;min-width:0;min-height:0}
body:not(.is-study-home) .modal{padding:max(12px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) max(12px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left));overscroll-behavior:contain}
body:not(.is-study-home) .sheet{max-width:560px;max-height:100%;border-radius:18px;font-family:var(--study-font,"Source Han Sans SC",sans-serif);background:#fff;line-height:1.55;scrollbar-width:thin;overscroll-behavior:contain}
body:not(.is-study-home) .sheet h2{font-size:clamp(22px,4vw,28px);line-height:1.4;overflow-wrap:anywhere}
body:not(.is-study-home) .sheet :is(ol,ul){font-size:16px;line-height:1.65}
body:not(.is-study-home) .sheet .btn{min-height:48px}
@supports(height:100dvh){body:not(.is-study-home) #app{height:100dvh}}
@media(min-width:700px){
  #game .stage{padding-top:12px;padding-left:24px;padding-right:24px}
  #game .gbar{padding-left:24px;padding-right:24px}
  #game .game-scope{padding-left:26px;padding-right:26px;font-size:13px}
  #game .tbar{margin-left:26px;margin-right:26px}
  #game .kbd .k{max-width:54px;min-height:50px;font-size:22px}
  #game .kbd .k.kfn{max-width:70px;font-size:18px}
  #game .opts{gap:14px}
  #game .opt{min-height:68px;font-size:21px}
  #game .duel .half{padding:14px;gap:12px}
  #game .duel .half .opt{min-height:58px;font-size:19px}
}
@media(max-width:380px){
  #game .gbar{gap:6px}
  #game .gtitle{gap:5px}
  #game .pill{padding:6px 9px;font-size:16px}
  #game .pill.compact{padding:6px}
  #game .icon-btn{width:44px;height:44px}
  #game .opt{font-size:17px;padding:8px 6px}
  #game .half{padding:6px;border-width:2px;gap:8px}
  #game .duel .half .opt{font-size:15px;padding:6px 3px}
  #game .half .hn{font-size:14px}
  #game .conn{gap:24px}
  #game .node{font-size:16px;padding:6px 5px}
  #game .copbox{grid-template-columns:repeat(2,minmax(0,1fr))}
  #stage[data-game="g08"] #wGrid{grid-template-columns:repeat(3,minmax(0,1fr))!important}
  #game .potion .wd{font-size:14px!important}
}
/* Short landscape phones keep moving playfields visible. Scrollable quiz games
   retain full-size answers; only their surrounding spacing becomes tighter. */
@media(max-height:500px) and (orientation:landscape){
  #game .gbar{padding-top:max(4px,env(safe-area-inset-top));padding-bottom:4px}
  #game .game-scope{padding-top:2px;padding-bottom:2px;max-height:40px}
  #game .tbar{height:6px;margin-top:3px;margin-bottom:3px}
  #game .stage{padding-top:4px;padding-bottom:max(8px,env(safe-area-inset-bottom))}
  #stage[data-game="g07"]{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);grid-template-rows:1fr auto;gap:6px 12px}
  #stage[data-game="g07"] #sky{grid-column:1;grid-row:1 / 3;width:100%;height:100%;min-height:0}
  #stage[data-game="g07"]>.center{grid-column:2;grid-row:1;align-self:end;padding:0!important}
  #stage[data-game="g07"] #kbHost{grid-column:2;grid-row:2;min-width:0;align-self:end}
  #stage[data-game="g07"] #typed{font-size:20px;min-height:24px!important;letter-spacing:1px!important}
  #stage[data-game="g07"] .kbd .k{min-height:36px;font-size:16px}
  #stage[data-game="g07"] .kbd>div{gap:3px!important}
  #stage[data-game="g09"] #fq{font-size:26px!important;line-height:1.25}
  #stage[data-game="g09"]>.center{gap:0!important}
  #game .stage.scroll>.center{gap:8px!important}
  body:not(.is-study-home) .sheet{padding:14px 18px}
  body:not(.is-study-home) .sheet .ico-lg{width:64px;height:64px;margin-bottom:8px}
}
