/* V209 — stable Harf Avı keyboard scene.
   The phone keyboard may resize only visualViewport on iOS. This final layer
   uses the measured visible height rather than layout-viewport media queries,
   keeps Menu / timer / Skip in one row, and fits all six attempts at once. */
@media (max-width:820px), (pointer:coarse) {
  body.ha-v111-playing.ha-v209-keyboard {
    overflow:hidden!important;
    overscroll-behavior:none!important;
  }

  body.ha-v111-playing.ha-v209-keyboard #gameScreen.active,
  body.ha-v111-playing.ha-v209-keyboard #multiScreen.active {
    position:fixed!important;
    inset:0!important;
    z-index:2147480000!important;
    display:block!important;
    width:100%!important;
    height:var(--ha-v209-visible-height,100dvh)!important;
    min-height:0!important;
    max-height:var(--ha-v209-visible-height,100dvh)!important;
    margin:0!important;
    padding:0!important;
    overflow:hidden!important;
    background:linear-gradient(180deg,rgba(248,249,242,.99),rgba(225,235,231,.99))!important;
  }

  body.ha-v111-playing.ha-v209-keyboard #gameScreen.active .game-layout,
  body.ha-v111-playing.ha-v209-keyboard #multiScreen.active .multi-grid {
    display:block!important;
    width:100%!important;
    height:100%!important;
    min-height:0!important;
    margin:0!important;
    padding:0!important;
    overflow:hidden!important;
  }

  body.ha-v111-playing.ha-v209-keyboard .game-main,
  body.ha-v111-playing.ha-v209-keyboard .multi-game {
    --ha-v209-cell:clamp(
      24px,
      min(10.2vw,calc((var(--ha-v209-visible-height,430px) - 154px) / 6 - 3px)),
      42px
    );
    position:relative!important;
    inset:auto!important;
    display:grid!important;
    grid-template-rows:46px auto minmax(0,1fr)!important;
    align-content:stretch!important;
    width:100%!important;
    height:100%!important;
    min-height:0!important;
    max-height:100%!important;
    margin:0!important;
    padding:4px 5px 58px!important;
    border:0!important;
    border-radius:0!important;
    overflow:hidden!important;
    box-shadow:none!important;
  }

  body.ha-v111-playing.ha-v209-keyboard .hud {
    position:relative!important;
    top:auto!important;
    z-index:4!important;
    display:grid!important;
    grid-template-columns:minmax(72px,1fr) 92px minmax(72px,1fr)!important;
    align-items:center!important;
    gap:5px!important;
    width:100%!important;
    height:46px!important;
    min-height:46px!important;
    margin:0 0 3px!important;
    padding:3px 5px!important;
    border-radius:14px!important;
    overflow:hidden!important;
  }

  body.ha-v111-playing.ha-v209-keyboard .hud-left,
  body.ha-v111-playing.ha-v209-keyboard .hud-right {
    display:flex!important;
    align-items:center!important;
    flex-wrap:nowrap!important;
    min-width:0!important;
    width:100%!important;
    gap:0!important;
  }
  body.ha-v111-playing.ha-v209-keyboard .hud-right { justify-content:flex-end!important; }
  body.ha-v111-playing.ha-v209-keyboard .hud .pill { display:none!important; }
  body.ha-v111-playing.ha-v209-keyboard .hud .ghost {
    display:flex!important;
    align-items:center!important;
    justify-content:center!important;
    width:100%!important;
    max-width:88px!important;
    min-width:0!important;
    min-height:38px!important;
    height:38px!important;
    padding:4px 7px!important;
    border-radius:11px!important;
    overflow:hidden!important;
    text-overflow:ellipsis!important;
    white-space:nowrap!important;
    font-size:11px!important;
    line-height:1!important;
  }
  body.ha-v111-playing.ha-v209-keyboard .timer-wrap {
    width:92px!important;
    min-width:92px!important;
    max-width:92px!important;
    margin:0 auto!important;
  }
  body.ha-v111-playing.ha-v209-keyboard .timer {
    font-size:29px!important;
    line-height:.95!important;
    letter-spacing:-.05em!important;
  }
  body.ha-v111-playing.ha-v209-keyboard .timer-bar {
    height:4px!important;
    margin-top:3px!important;
  }

  body.ha-v111-playing.ha-v209-keyboard .status {
    display:-webkit-box!important;
    -webkit-box-orient:vertical!important;
    -webkit-line-clamp:2!important;
    align-self:start!important;
    width:100%!important;
    min-height:28px!important;
    max-height:34px!important;
    margin:0 0 3px!important;
    padding:4px 7px!important;
    border-radius:10px!important;
    overflow:hidden!important;
    font-size:9px!important;
    line-height:1.18!important;
  }

  body.ha-v111-playing.ha-v209-keyboard .board-wrap,
  body.ha-v111-playing.ha-v209-keyboard #gameScreen .board-wrap,
  body.ha-v111-playing.ha-v209-keyboard #multiScreen .board-wrap {
    display:flex!important;
    align-items:center!important;
    justify-content:center!important;
    width:100%!important;
    height:100%!important;
    min-height:0!important;
    max-height:none!important;
    margin:0!important;
    padding:1px 0!important;
    overflow:hidden!important;
    overscroll-behavior:none!important;
    touch-action:none!important;
  }

  body.ha-v111-playing.ha-v209-keyboard .board,
  body.ha-v111-playing.ha-v209-keyboard #board,
  body.ha-v111-playing.ha-v209-keyboard #multiBoard {
    --cell:var(--ha-v209-cell)!important;
    align-self:center!important;
    margin:0 auto!important;
    gap:3px!important;
    transform:none!important;
  }
  body.ha-v111-playing.ha-v209-keyboard .board .row,
  body.ha-v111-playing.ha-v209-keyboard #board .row,
  body.ha-v111-playing.ha-v209-keyboard #multiBoard .row {
    height:var(--ha-v209-cell)!important;
    min-height:var(--ha-v209-cell)!important;
    margin:0!important;
    gap:3px!important;
  }
  body.ha-v111-playing.ha-v209-keyboard .cell {
    width:var(--ha-v209-cell)!important;
    height:var(--ha-v209-cell)!important;
    min-width:var(--ha-v209-cell)!important;
    min-height:var(--ha-v209-cell)!important;
    border-width:1px!important;
    border-radius:clamp(6px,1.8vw,9px)!important;
    box-shadow:inset 0 -2px 0 rgba(0,0,0,.10)!important;
    font-size:clamp(13px,4.3vw,20px)!important;
  }

  body.ha-v111-playing.ha-v209-keyboard #singleNativeEntry,
  body.ha-v111-playing.ha-v209-keyboard #multiNativeEntry,
  body.ha-v111-playing.ha-v209-keyboard #gameScreen.active #singleNativeEntry,
  body.ha-v111-playing.ha-v209-keyboard #multiScreen.active #multiNativeEntry {
    position:absolute!important;
    left:5px!important;
    right:5px!important;
    bottom:max(4px,env(safe-area-inset-bottom))!important;
    z-index:8!important;
    display:grid!important;
    grid-template-columns:40px minmax(0,1fr) 82px!important;
    width:auto!important;
    max-width:none!important;
    height:52px!important;
    margin:0!important;
    padding:4px!important;
    gap:4px!important;
    border-radius:14px!important;
  }
  body.ha-v111-playing.ha-v209-keyboard .mobile-native-prefix,
  body.ha-v111-playing.ha-v209-keyboard .mobile-native-entry input,
  body.ha-v111-playing.ha-v209-keyboard .mobile-native-submit {
    height:42px!important;
    min-height:42px!important;
  }
  body.ha-v111-playing.ha-v209-keyboard .mobile-native-entry input {
    min-width:0!important;
    padding:0 8px!important;
    font-size:16px!important;
  }
  body.ha-v111-playing.ha-v209-keyboard .mobile-native-submit {
    min-width:0!important;
    padding:0 5px!important;
    font-size:10px!important;
    white-space:nowrap!important;
  }
  body.ha-v111-playing.ha-v209-keyboard .keyboard,
  body.ha-v111-playing.ha-v209-keyboard .kbd-hint,
  body.ha-v111-playing.ha-v209-keyboard .game-layout > .side,
  body.ha-v111-playing.ha-v209-keyboard #multiScreen .multi-page-head,
  body.ha-v111-playing.ha-v209-keyboard #multiScreen .multi-lobby-grid {
    display:none!important;
  }

  body.ha-v111-playing.ha-v209-keyboard.ha-v209-short .game-main,
  body.ha-v111-playing.ha-v209-keyboard.ha-v209-short .multi-game {
    grid-template-rows:42px auto minmax(0,1fr)!important;
    padding-top:3px!important;
  }
  body.ha-v111-playing.ha-v209-keyboard.ha-v209-short .hud {
    height:42px!important;
    min-height:42px!important;
    padding:2px 4px!important;
  }
  body.ha-v111-playing.ha-v209-keyboard.ha-v209-short .hud .ghost {
    height:34px!important;
    min-height:34px!important;
    font-size:10px!important;
  }
  body.ha-v111-playing.ha-v209-keyboard.ha-v209-short .timer { font-size:25px!important; }
  body.ha-v111-playing.ha-v209-keyboard.ha-v209-short .status {
    min-height:24px!important;
    max-height:28px!important;
    padding:3px 6px!important;
    font-size:8px!important;
  }

  body.ha-v111-playing.ha-v209-keyboard.ha-v209-very-short .game-main,
  body.ha-v111-playing.ha-v209-keyboard.ha-v209-very-short .multi-game {
    --ha-v209-cell:clamp(22px,min(9.6vw,calc((var(--ha-v209-visible-height,340px) - 133px) / 6 - 3px)),36px);
    grid-template-rows:40px 22px minmax(0,1fr)!important;
    padding:2px 4px 54px!important;
  }
  body.ha-v111-playing.ha-v209-keyboard.ha-v209-very-short .hud {
    height:40px!important;
    min-height:40px!important;
    margin-bottom:2px!important;
  }
  body.ha-v111-playing.ha-v209-keyboard.ha-v209-very-short .status {
    min-height:22px!important;
    max-height:22px!important;
    margin-bottom:1px!important;
    -webkit-line-clamp:1!important;
  }
  body.ha-v111-playing.ha-v209-keyboard.ha-v209-very-short #singleNativeEntry,
  body.ha-v111-playing.ha-v209-keyboard.ha-v209-very-short #multiNativeEntry {
    height:48px!important;
  }
  body.ha-v111-playing.ha-v209-keyboard.ha-v209-very-short .mobile-native-prefix,
  body.ha-v111-playing.ha-v209-keyboard.ha-v209-very-short .mobile-native-entry input,
  body.ha-v111-playing.ha-v209-keyboard.ha-v209-very-short .mobile-native-submit {
    height:38px!important;
    min-height:38px!important;
  }
}

/* V209 specificity lock: older V158/V159 rules use #gameScreen selectors.
   Keep this block last so those historical iPhone offsets cannot win. */
@media (max-width:820px), (pointer:coarse) {
  html body.ha-v111-playing.ha-v209-keyboard #gameScreen.active .game-main,
  html body.ha-v111-playing.ha-v209-keyboard #multiScreen.active .multi-game {
    display:grid!important;
    grid-template-rows:46px auto minmax(0,1fr)!important;
    width:100%!important;
    height:100%!important;
    min-height:0!important;
    max-height:100%!important;
    margin:0!important;
    padding:4px 5px 58px!important;
    overflow:hidden!important;
  }
  html body.ha-v111-playing.ha-v209-keyboard #gameScreen.active .hud,
  html body.ha-v111-playing.ha-v209-keyboard #multiScreen.active .hud {
    position:relative!important;
    top:auto!important;
    display:grid!important;
    grid-template-columns:minmax(72px,1fr) 92px minmax(72px,1fr)!important;
    gap:5px!important;
    width:100%!important;
    height:46px!important;
    min-height:46px!important;
    margin:0 0 3px!important;
    padding:3px 5px!important;
  }
  html body.ha-v111-playing.ha-v209-keyboard #gameScreen.active .hud-left,
  html body.ha-v111-playing.ha-v209-keyboard #gameScreen.active .hud-right,
  html body.ha-v111-playing.ha-v209-keyboard #multiScreen.active .hud-left,
  html body.ha-v111-playing.ha-v209-keyboard #multiScreen.active .hud-right {
    display:flex!important;
    align-items:center!important;
    flex-wrap:nowrap!important;
    width:100%!important;
    min-width:0!important;
  }
  html body.ha-v111-playing.ha-v209-keyboard #gameScreen.active #backBtn,
  html body.ha-v111-playing.ha-v209-keyboard #gameScreen.active #newWordBtn,
  html body.ha-v111-playing.ha-v209-keyboard #multiScreen.active .hud .ghost {
    width:100%!important;
    max-width:88px!important;
    min-width:0!important;
    height:38px!important;
    min-height:38px!important;
    padding:4px 7px!important;
    font-size:11px!important;
  }
  html body.ha-v111-playing.ha-v209-keyboard #gameScreen.active .timer-wrap,
  html body.ha-v111-playing.ha-v209-keyboard #multiScreen.active .timer-wrap {
    width:92px!important;
    min-width:92px!important;
    max-width:92px!important;
    padding:0!important;
  }
  html body.ha-v111-playing.ha-v209-keyboard #gameScreen.active #timerText,
  html body.ha-v111-playing.ha-v209-keyboard #multiScreen.active .timer {
    font-size:29px!important;
    line-height:.95!important;
  }
  html body.ha-v111-playing.ha-v209-keyboard #gameScreen.active .status,
  html body.ha-v111-playing.ha-v209-keyboard #multiScreen.active .status {
    min-height:28px!important;
    max-height:34px!important;
    margin:0 0 3px!important;
    padding:4px 7px!important;
    font-size:9px!important;
    line-height:1.18!important;
  }
  html body.ha-v111-playing.ha-v209-keyboard #gameScreen.active .board-wrap,
  html body.ha-v111-playing.ha-v209-keyboard #multiScreen.active .board-wrap {
    align-items:center!important;
    width:100%!important;
    height:100%!important;
    min-height:0!important;
    max-height:none!important;
    margin:0!important;
    padding:1px 0!important;
    overflow:hidden!important;
  }
  html body.ha-v111-playing.ha-v209-keyboard #gameScreen.active #board,
  html body.ha-v111-playing.ha-v209-keyboard #multiScreen.active #multiBoard {
    transform:none!important;
    margin:0 auto!important;
  }

  html body.ha-v111-playing.ha-v209-keyboard.ha-v209-short #gameScreen.active .game-main,
  html body.ha-v111-playing.ha-v209-keyboard.ha-v209-short #multiScreen.active .multi-game {
    grid-template-rows:42px auto minmax(0,1fr)!important;
    padding:3px 5px 58px!important;
  }
  html body.ha-v111-playing.ha-v209-keyboard.ha-v209-short #gameScreen.active .hud,
  html body.ha-v111-playing.ha-v209-keyboard.ha-v209-short #multiScreen.active .hud {
    height:42px!important;
    min-height:42px!important;
    padding:2px 4px!important;
  }
  html body.ha-v111-playing.ha-v209-keyboard.ha-v209-short #gameScreen.active #backBtn,
  html body.ha-v111-playing.ha-v209-keyboard.ha-v209-short #gameScreen.active #newWordBtn,
  html body.ha-v111-playing.ha-v209-keyboard.ha-v209-short #multiScreen.active .hud .ghost {
    height:34px!important;
    min-height:34px!important;
    font-size:10px!important;
  }
  html body.ha-v111-playing.ha-v209-keyboard.ha-v209-short #gameScreen.active #timerText,
  html body.ha-v111-playing.ha-v209-keyboard.ha-v209-short #multiScreen.active .timer {
    font-size:25px!important;
  }
  html body.ha-v111-playing.ha-v209-keyboard.ha-v209-short #gameScreen.active .status,
  html body.ha-v111-playing.ha-v209-keyboard.ha-v209-short #multiScreen.active .status {
    min-height:24px!important;
    max-height:28px!important;
    margin:0 0 2px!important;
    padding:3px 6px!important;
    font-size:8px!important;
  }

  html body.ha-v111-playing.ha-v209-keyboard.ha-v209-very-short #gameScreen.active .game-main,
  html body.ha-v111-playing.ha-v209-keyboard.ha-v209-very-short #multiScreen.active .multi-game {
    grid-template-rows:40px 22px minmax(0,1fr)!important;
    padding:2px 4px 54px!important;
  }
  html body.ha-v111-playing.ha-v209-keyboard.ha-v209-very-short #gameScreen.active .hud,
  html body.ha-v111-playing.ha-v209-keyboard.ha-v209-very-short #multiScreen.active .hud {
    height:40px!important;
    min-height:40px!important;
    margin-bottom:2px!important;
  }
  html body.ha-v111-playing.ha-v209-keyboard.ha-v209-very-short #gameScreen.active .status,
  html body.ha-v111-playing.ha-v209-keyboard.ha-v209-very-short #multiScreen.active .status {
    min-height:22px!important;
    max-height:22px!important;
    margin-bottom:1px!important;
  }
}
