/* WordGrid mobile game layer */
.wg-mobile-keyboard,.wg-fullscreen-btn{display:none}

@media (max-width:900px){
  body.wg-kbd-open{padding-bottom:calc(var(--wg-keyboard-height,196px) + 8px)}
  .game-card{overflow:visible!important}
  .game-hud{
    position:sticky!important;top:60px!important;z-index:70!important;
    margin:-2px -2px 7px!important;padding:6px 47px 6px 6px!important;
    border:1px solid rgba(220,224,233,.94)!important;border-radius:13px!important;
    background:rgba(249,250,253,.97)!important;
    box-shadow:0 8px 24px rgba(25,32,50,.12)!important;
    backdrop-filter:blur(18px);-webkit-backdrop-filter:blur(18px)
  }
  .game-stats{
    display:grid!important;grid-template-columns:repeat(4,minmax(0,1fr))!important;
    gap:4px!important;margin:0 0 5px!important
  }
  .stat{
    min-width:0!important;padding:6px 7px!important;
    border:1px solid #e5e8ef!important;border-radius:8px!important;
    background:linear-gradient(180deg,#fff 0%,#f7f8fb 100%)!important
  }
  .stat span{
    display:block!important;margin-bottom:2px!important;color:#98a2b3!important;
    font-size:6.5px!important;font-weight:850!important;line-height:1!important;
    letter-spacing:.07em!important;text-transform:uppercase!important;white-space:nowrap!important
  }
  .stat strong{
    display:block!important;color:#28344c!important;font-size:11px!important;
    font-weight:850!important;line-height:1.05!important;font-variant-numeric:tabular-nums!important
  }
  .wg-fullscreen-btn{
    position:absolute;top:6px;right:6px;z-index:2;display:grid;place-items:center;
    width:36px;height:36px;padding:0;border:1px solid #d9deea;border-radius:9px;
    background:#fff;color:#374151;font-size:18px;font-weight:900;
    box-shadow:0 1px 2px rgba(15,23,42,.05)
  }
  .wg-fullscreen-btn:active{transform:scale(.96);background:#eef0ff}

  .toolbar{
    display:flex!important;flex-wrap:nowrap!important;gap:4px!important;
    margin-bottom:5px!important;overflow-x:auto!important;scrollbar-width:none!important
  }
  .toolbar::-webkit-scrollbar{display:none}
  .tool{
    flex:0 0 auto!important;padding:7px 10px!important;border-radius:8px!important;
    font-size:9px!important;line-height:1!important
  }

  .active-clue-bar{
    min-height:42px!important;margin:0 0 5px!important;padding:7px 9px!important;
    border:1px solid #e3dec0!important;border-radius:9px!important;
    background:linear-gradient(180deg,#fffdf5 0%,#fff9df 100%)!important;
    box-shadow:inset 3px 0 0 #d7bb50!important
  }
  .active-clue-bar strong{font-size:11px!important;line-height:1.18!important}
  .active-clue-bar>span{font-size:7px!important}
  .zoom-control{gap:3px!important;margin-left:auto!important}
  .zoom-control button{width:28px!important;height:28px!important;border-radius:7px!important}
  .zoom-control output{min-width:38px!important;font-size:10px!important}

  .active-answer-bar{
    display:flex!important;align-items:center!important;gap:7px!important;
    min-height:38px!important;margin:0!important;padding:5px 7px!important;
    border:1px solid #dfe4ef!important;border-radius:8px!important;background:#fff!important
  }
  .answer-slots{gap:3px!important}
  .answer-slot{
    min-width:26px!important;height:28px!important;padding:0!important;
    border-radius:6px!important;font-size:14px!important
  }
  .answer-slot.wg-current{
    border:2px solid #5657e6!important;background:#eef0ff!important
  }
  .intersection-switch{
    flex:none;margin-left:auto;padding:7px 8px;border:1px solid #d9ddf4;border-radius:7px;
    background:#f1f1ff;color:#5052c9;font-size:8.5px;font-weight:850;line-height:1;
    white-space:nowrap;touch-action:manipulation
  }
  .intersection-switch[hidden]{display:none!important}
  .intersection-switch:active{transform:scale(.97);background:#e5e6ff}

  .sg-cell.letter.active{
    background:#e8f0ff!important;
    box-shadow:inset 0 0 0 1px rgba(86,87,230,.34)!important
  }
  .sg-cell.letter.active.correct{background:#e0f5e8!important}
  .sg-cell.letter.active.wrong{background:#ffe4e2!important}
  .sg-cell.letter input{pointer-events:none!important;caret-color:transparent!important}
  .sg-cell.letter.wg-cursor{
    background:#fff3b0!important;
    box-shadow:inset 0 0 0 3px #5657e6!important;
    z-index:6
  }

  .wg-mobile-keyboard{
    position:fixed;left:0;right:0;bottom:0;z-index:140;display:none;
    padding:6px 5px calc(6px + env(safe-area-inset-bottom));
    border-top:1px solid #d5dae4;background:rgba(241,243,247,.985);
    box-shadow:0 -10px 30px rgba(15,23,42,.16);
    backdrop-filter:blur(18px);-webkit-backdrop-filter:blur(18px)
  }
  .wg-mobile-keyboard.open{display:block}
  .wg-mobile-keyboard::before{
    content:"";
    display:block;
    width:42px;height:4px;
    margin:0 auto 6px;
    border-radius:999px;
    background:#aeb6c4
  }
  .wg-mobile-keyboard::after{
    content:"свайп вниз — скрыть";
    display:block;
    margin:-1px auto 5px;
    color:#8a94a4;
    font-size:8px;
    font-weight:750;
    letter-spacing:.03em;
    text-align:center
  }
  .wg-kbd-nav,.wg-kbd-row{
    display:flex;justify-content:center;gap:4px;max-width:620px;margin:0 auto 4px
  }
  .wg-kbd-nav{margin-bottom:6px}
  .wg-key{
    flex:1 1 0;min-width:0;max-width:45px;height:39px;padding:0;
    border:1px solid #d8dde6;border-bottom-color:#b9c0cc;border-radius:7px;
    background:#fff;color:#111827;font-size:17px;font-weight:780;line-height:1;
    box-shadow:0 1px 1px rgba(15,23,42,.08);touch-action:manipulation;
    -webkit-tap-highlight-color:transparent
  }
  .wg-key:active{background:#e7eaf0;transform:translateY(1px)}
  .wg-key.wg-action{max-width:68px;background:#e1e5ec;font-size:13px}
  .wg-key.wg-word{max-width:88px;font-size:10px;font-weight:800}
  .wg-key.wg-hide{max-width:46px;font-size:18px}
  .wg-key.wg-undo{max-width:46px;font-size:19px;font-weight:900}
  .wg-key:disabled{opacity:.42;box-shadow:none}
  .wg-key.wg-backspace{max-width:58px;font-size:20px}
  .wg-kbd-row.wg-row2{padding:0 14px}
  .wg-kbd-row.wg-row3{padding:0 5px}

  body.wg-fullscreen{overflow-x:hidden!important}
  body.wg-fullscreen header,
  body.wg-fullscreen footer,
  body.wg-fullscreen .page-head,
  body.wg-fullscreen .game-side,
  body.wg-fullscreen .post-nav,
  body.wg-fullscreen .keyboard-note{display:none!important}
  body.wg-fullscreen main{min-height:100dvh!important}
  body.wg-fullscreen main>.wrap{width:100%!important;max-width:none!important;margin:0!important;padding:0!important}
  body.wg-fullscreen .game-wrap{display:block!important;min-height:100dvh!important;padding:0!important}
  body.wg-fullscreen .game-card{
    min-height:100dvh!important;margin:0!important;padding:3px!important;
    border:0!important;border-radius:0!important;box-shadow:none!important;background:#f7f8fb!important
  }
  body.wg-fullscreen .game-hud{top:0!important;margin:0 0 4px!important;border-radius:0 0 11px 11px!important}
  body.wg-fullscreen .grid-viewport{max-width:100vw!important}
  body.wg-fullscreen .wg-fullscreen-btn{background:#eef0ff;color:#4546c9;border-color:#d8dbff}
}

@media (min-width:901px){
  .wg-fullscreen-btn{
    display:grid;place-items:center;position:absolute;top:8px;right:8px;
    width:36px;height:36px;border:1px solid #d9deea;border-radius:9px;
    background:#fff;color:#374151;font-size:18px
  }
  body.wg-fullscreen header,body.wg-fullscreen footer,body.wg-fullscreen .page-head,body.wg-fullscreen .game-side{display:none!important}
  body.wg-fullscreen main>.wrap{width:min(100% - 20px,1400px)!important;max-width:none!important}
  body.wg-fullscreen .game-wrap{grid-template-columns:1fr!important}
}

/* Compact game navigator: current word + live minimap */
@media(max-width:900px){
  .wg-game-nav{
    display:flex;align-items:center;gap:6px;
    margin-top:5px;padding-top:5px;border-top:1px solid #e7eaf0
  }
  .wg-current-word-btn{
    flex:none;display:flex;align-items:center;gap:5px;
    height:42px;padding:0 10px;border:1px solid #d9deea;border-radius:8px;
    background:#fff;color:#3b4353;font-size:10px;font-weight:850;
    white-space:nowrap
  }
  .wg-current-word-btn span{color:#5657e6;font-size:16px;line-height:1}
  .wg-minimap-wrap{
    position:relative;flex:1;min-width:0;height:42px;
    overflow:hidden;border:1px solid #d5dae4;border-radius:8px;
    background:#e7eaf0;cursor:pointer
  }
  .wg-minimap{display:block;width:100%;height:100%;touch-action:manipulation}
  body.wg-fullscreen .wg-game-nav{margin-top:3px;padding-top:3px}
}
/* Phone-first solving mode */
@media(max-width:900px){
  .grid-viewport{touch-action:pan-x pan-y;overscroll-behavior:contain}
  .sg-cell,.clue-part,.answer-slot,.wg-key,.tool,.zoom-control button,.wg-current-word-btn{
    -webkit-tap-highlight-color:transparent
  }

  body.wg-kbd-open header,
  body.wg-kbd-open .page-head,
  body.wg-kbd-open .game-side,
  body.wg-kbd-open .keyboard-note{
    display:none!important
  }
  body.wg-kbd-open .game-card{padding-top:0!important}
  body.wg-kbd-open .game-hud{
    top:0!important;
    margin:0 0 4px!important;
    padding:5px 47px 5px 5px!important;
    border-radius:0 0 10px 10px!important
  }
  body.wg-kbd-open .game-stats,
  body.wg-kbd-open .toolbar{
    display:none!important
  }
  body.wg-kbd-open .active-clue-bar{
    min-height:39px!important;
    margin-bottom:4px!important
  }
  body.wg-kbd-open .active-clue-bar .zoom-control{
    display:none!important
  }
  body.wg-kbd-open .active-answer-bar{
    margin-bottom:3px!important
  }
  body.wg-kbd-open .wg-game-nav{
    margin-top:3px!important;
    padding-top:3px!important
  }

  .wg-mobile-keyboard{
    padding-top:5px
  }
  .wg-key{
    height:42px;
    border-radius:8px;
    font-size:18px
  }
  .wg-key.wg-action{font-size:13px}
  .wg-key.wg-word{font-size:10px}
  .wg-key.wg-backspace{font-size:20px}
}

@media(max-width:390px){
  body.wg-kbd-open{padding-bottom:calc(var(--wg-keyboard-height,202px) + 8px)}
  .wg-key{height:40px;font-size:17px}
  .wg-kbd-nav,.wg-kbd-row{gap:3px}
  .intersection-switch{max-width:94px;padding:7px 6px;font-size:7.5px;overflow:hidden;text-overflow:ellipsis}
}

/* Long-press backspace clears the active word */
@media(max-width:900px){
  .wg-key.wg-backspace{position:relative}
  .wg-key.wg-backspace::after{
    content:"слово";
    position:absolute;left:50%;bottom:2px;transform:translateX(-50%);
    font-size:5.5px;font-weight:850;letter-spacing:.02em;color:#7b8493;
    line-height:1;pointer-events:none
  }
}


/* Feedback for a correctly completed answer */
@keyframes wgWordComplete{
  0%{transform:scale(1);filter:none}
  45%{transform:scale(.96);filter:saturate(1.18)}
  100%{transform:scale(1);filter:none}
}
@media(max-width:900px){
  .sg-cell.letter.wg-word-complete{
    z-index:3;
    background:#dff5e7!important;
    box-shadow:inset 0 0 0 2px #4aa96c!important;
    animation:wgWordComplete .38s ease both
  }
}
