/* r740 — game UI completeness hotfix
   Loaded LAST on all game surfaces.
   Goals: no clipped labels/settings/categories; complete Qadha board; uncropped host drawing. */

/* ---------- Universal game copy: never ellipsize meaningful UI text ---------- */
body[data-game-brand] :is(
  h1,h2,h3,h4,p,label,legend,small,strong,
  .field label,.field small,.section-title,.section-subtitle,.setup-card,.setup-card p,.setup-card small,
  .segment,.sound-option,.mode-toggle,.option-switch,.category-choice,.category-card,.category-card h3,.category-card p,
  .cat-card,.cat-card h3,.cat-card p,.preset-chip,.qadha-pack-chip,.round-option,.timer-option,
  .question-text,.question-copy,.answer-box,.answer-copy,.result-answer,.revealed-content,
  .team-name,.player-name,.participant-name,.scoreboard-name,
  .q-board-slogan,.board-cat strong,.team-name-button strong
){
  white-space:normal!important;
  text-overflow:clip!important;
  -webkit-line-clamp:unset!important;
  -webkit-box-orient:initial!important;
  max-height:none!important;
  overflow-wrap:anywhere!important;
  word-break:normal!important;
}

body[data-game-brand] :is(
  .segment,.sound-option,.mode-toggle,.option-switch,.category-choice,.round-option,.timer-option,
  .setup-card button,.setup-card .btn,.cat-card,.category-card
){
  height:auto!important;
  min-height:46px!important;
}

body[data-game-brand] :is(
  .setup-grid,.settings-grid,.category-grid,.categories-grid,.preset-grid,.mode-grid,.options-grid
){
  align-items:stretch!important;
}

body[data-game-brand] :is(
  .setup-card,.field,.cat-card,.category-card,.mode-card,.option-card,
  .segment,.mode-toggle,.option-switch
){
  min-width:0!important;
  overflow:visible!important;
}

/* Keep controls readable rather than cutting their text to a single line. */
body[data-game-brand] :is(button,.btn,.segment,.mode-toggle,.option-switch,.category-choice,.q-toolbar-action){
  white-space:normal!important;
  text-overflow:clip!important;
  line-height:1.35!important;
}

/* ---------- Qadha setup/category completeness ---------- */
body[data-game-brand="qadha"] .category-grid{
  grid-auto-rows:auto!important;
}
body[data-game-brand="qadha"] .cat-card{
  display:grid!important;
  grid-template-rows:auto auto auto 1fr!important;
  align-content:start!important;
  min-height:210px!important;
  overflow:visible!important;
}
body[data-game-brand="qadha"] .cat-card .cat-cover{
  height:84px!important;
}
body[data-game-brand="qadha"] .cat-card h3{
  min-height:0!important;
  margin:8px 0 5px!important;
  line-height:1.35!important;
}
body[data-game-brand="qadha"] .cat-card p{
  display:block!important;
  min-height:0!important;
  line-height:1.6!important;
  overflow:visible!important;
}
body[data-game-brand="qadha"] .qadha-pack-strip,
body[data-game-brand="qadha"] .setup-grid,
body[data-game-brand="qadha"] .help-setup-grid{
  min-width:0!important;
}
body[data-game-brand="qadha"] .qadha-pack-chip{
  min-width:0!important;
  min-height:46px!important;
  height:auto!important;
  padding-block:9px!important;
}

/* ---------- Qadha board: fit the whole approved board in one desktop/TV viewport ---------- */
@media (min-width:901px) and (min-height:620px){
  html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active:not(.qadha-drawing-focus){
    height:100dvh!important;
    min-height:100dvh!important;
    overflow:hidden!important;
  }
  html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active:not(.qadha-drawing-focus) #qApp{
    height:100dvh!important;
    min-height:0!important;
    padding:6px 10px 8px!important;
    overflow:hidden!important;
  }
  html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active:not(.qadha-drawing-focus) .qadha-reference-board{
    width:min(1680px,100%)!important;
    height:calc(100dvh - 28px)!important;
    min-height:0!important;
    max-height:calc(100dvh - 28px)!important;
    grid-template-rows:auto minmax(0,1fr) auto!important;
    gap:8px!important;
    overflow:hidden!important;
  }
  html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active:not(.qadha-drawing-focus) .premium-qadha-toolbar{
    min-height:52px!important;
    padding-block:3px!important;
  }
  html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active:not(.qadha-drawing-focus) .premium-board-grid.qadha-reference-grid{
    min-height:0!important;
    grid-template-columns:repeat(3,minmax(0,1fr))!important;
    grid-template-rows:repeat(2,minmax(0,1fr))!important;
    grid-auto-rows:minmax(0,1fr)!important;
    gap:8px!important;
    overflow:hidden!important;
  }
  html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active:not(.qadha-drawing-focus) .board-category-panel{
    min-height:0!important;
    height:100%!important;
    padding:6px!important;
    gap:6px!important;
  }
  html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active:not(.qadha-drawing-focus) .board-category-panel .board-cat-art{
    min-height:0!important;
    max-height:none!important;
  }
  html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active:not(.qadha-drawing-focus) .board-category-panel .board-cat strong{
    min-height:34px!important;
    padding:4px 5px!important;
    display:grid!important;
    place-items:center!important;
  }
  html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active:not(.qadha-drawing-focus) .category-value-column{
    grid-template-rows:repeat(3,minmax(34px,1fr))!important;
    gap:5px!important;
  }
  html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active:not(.qadha-drawing-focus) .premium-board-footer.qadha-reference-footer{
    min-height:96px!important;
    max-height:112px!important;
    gap:8px!important;
  }
  html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active:not(.qadha-drawing-focus) .premium-team-box{
    min-height:92px!important;
    padding:7px 10px!important;
  }
}

/* Short landscape hosts must scroll instead of cropping the lower board/footer. */
@media (max-height:619px) and (orientation:landscape){
  html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active:not(.qadha-drawing-focus),
  html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active:not(.qadha-drawing-focus) #qApp{
    height:auto!important;
    min-height:100dvh!important;
    overflow-y:auto!important;
  }
  html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active:not(.qadha-drawing-focus) .qadha-reference-board{
    height:auto!important;
    min-height:680px!important;
    max-height:none!important;
    overflow:visible!important;
  }
}

/* ---------- Qadha drawing host: reserve the full workspace and CONTAIN the 900×560 canvas ---------- */
html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active.qadha-drawing-focus #qApp{
  height:100dvh!important;
  min-height:0!important;
  padding:4px 7px!important;
  overflow:hidden!important;
}
html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active.qadha-drawing-focus .q-question-screen-v129{
  height:calc(100dvh - 8px)!important;
  min-height:0!important;
  max-height:calc(100dvh - 8px)!important;
  overflow:hidden!important;
}
html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active.qadha-drawing-focus .q-question-body-v129,
html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active.qadha-drawing-focus .q-question-stage-v129,
html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active.qadha-drawing-focus .question-card,
html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active.qadha-drawing-focus .q-question-content-scroll,
html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active.qadha-drawing-focus .drawing-stage-v260,
html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active.qadha-drawing-focus .drawing-workspace-v260{
  min-height:0!important;
  overflow:hidden!important;
}
html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active.qadha-drawing-focus .drawing-workspace-v260{
  grid-template-rows:auto auto minmax(0,1fr)!important;
}
html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active.qadha-drawing-focus .host-draw-paper{
  width:100%!important;
  height:100%!important;
  min-width:0!important;
  min-height:0!important;
  max-width:none!important;
  max-height:none!important;
  aspect-ratio:auto!important;
  margin:0!important;
  padding:5px!important;
  display:grid!important;
  place-items:center!important;
  overflow:hidden!important;
  background:#f7f7f7!important;
}
html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active.qadha-drawing-focus .host-draw-canvas{
  display:block!important;
  width:auto!important;
  height:auto!important;
  max-width:100%!important;
  max-height:100%!important;
  aspect-ratio:900/560!important;
  object-fit:contain!important;
  margin:auto!important;
  flex:none!important;
}
/* Give the drawing more space than QR/chrome. */
html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active.qadha-drawing-focus .drawing-stage-v260{
  grid-template-columns:clamp(105px,10vw,145px) minmax(0,1fr)!important;
  gap:7px!important;
}
html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active.qadha-drawing-focus .drawing-host-heading{
  min-height:30px!important;
  padding:2px 5px!important;
}
html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active.qadha-drawing-focus .host-draw-observer{
  min-height:22px!important;
  padding:2px 6px!important;
}
html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active.qadha-drawing-focus .q-question-control-dock{
  min-height:58px!important;
  padding:4px!important;
}
@media (max-width:900px){
  html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active.qadha-drawing-focus,
  html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active.qadha-drawing-focus #qApp,
  html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active.qadha-drawing-focus .q-question-screen-v129{
    height:auto!important;
    min-height:100dvh!important;
    max-height:none!important;
    overflow-y:auto!important;
  }
  html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active.qadha-drawing-focus .drawing-stage-v260{
    grid-template-columns:1fr!important;
    overflow:visible!important;
  }
  html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active.qadha-drawing-focus .drawing-workspace-v260,
  html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active.qadha-drawing-focus .host-draw-paper{
    height:auto!important;
    overflow:visible!important;
  }
  html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active.qadha-drawing-focus .host-draw-paper{
    aspect-ratio:900/560!important;
  }
}

/* ---------- Small screens: preserve full labels instead of shrinking/cropping them ---------- */
@media (max-width:720px){
  body[data-game-brand] :is(.segment,.mode-toggle,.option-switch,.category-choice,.cat-card,.category-card){
    min-height:48px!important;
  }
  body[data-game-brand="qadha"] .category-grid{
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    gap:10px!important;
  }
  body[data-game-brand="qadha"] .cat-card{
    min-height:224px!important;
    padding:11px!important;
  }
}
@media (max-width:420px){
  body[data-game-brand="qadha"] .category-grid{
    grid-template-columns:1fr!important;
  }
  body[data-game-brand="qadha"] .cat-card{
    min-height:0!important;
  }
}


/* r740b — mobile Qadha account control: icon/avatar only, no hidden username box overflow. */
@media (max-width:760px){
  :root[data-ui-mode="modern"] body[data-game-brand="qadha"] .q-nav nav > #qAccountBtn{
    width:44px!important;
    min-width:44px!important;
    max-width:44px!important;
    height:44px!important;
    min-height:44px!important;
    max-height:44px!important;
    padding:0!important;
    overflow:hidden!important;
    display:grid!important;
    place-items:center!important;
    line-height:1!important;
  }
  :root[data-ui-mode="modern"] body[data-game-brand="qadha"] .q-nav nav > #qAccountBtn > span{
    display:none!important;
  }
  :root[data-ui-mode="modern"] body[data-game-brand="qadha"] .q-nav nav > #qAccountBtn :is(img,.account-avatar,.q-account-avatar){
    width:30px!important;
    height:30px!important;
    min-width:30px!important;
    min-height:30px!important;
    max-width:30px!important;
    max-height:30px!important;
    object-fit:cover!important;
    border-radius:50%!important;
  }
}


/* r740c — eliminate intrinsic inline-image baseline from compact Qadha account button. */
@media (max-width:760px){
  :root[data-ui-mode="modern"] body[data-game-brand="qadha"] #qAccountBtn{
    box-sizing:border-box!important;
    font-size:0!important;
    line-height:0!important;
    gap:0!important;
  }
  :root[data-ui-mode="modern"] body[data-game-brand="qadha"] #qAccountBtn .q-account-avatar{
    display:block!important;
    margin:0!important;
    padding:0!important;
    vertical-align:top!important;
  }
}


/* r740d — desktop/TV Qadha: make the final loaded layer authoritative for viewport + footer placement. */
@media (min-width:901px) and (min-height:620px){
  html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active #qApp{
    position:fixed!important;
    inset:0!important;
    top:0!important;
    left:0!important;
    right:0!important;
    bottom:0!important;
    width:100vw!important;
    max-width:none!important;
    height:100dvh!important;
    max-height:none!important;
    min-height:0!important;
    margin:0!important;
    transform:none!important;
    transform-origin:center!important;
    box-sizing:border-box!important;
  }
  html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active:not(.qadha-drawing-focus) .premium-board-footer.qadha-reference-footer{
    grid-template-rows:minmax(0,1fr)!important;
    align-items:stretch!important;
    overflow:visible!important;
  }
  html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active:not(.qadha-drawing-focus) .premium-board-footer.qadha-reference-footer > .premium-team-box{
    grid-row:1!important;
    align-self:stretch!important;
    height:100%!important;
    min-height:0!important;
    max-height:100%!important;
    margin:0!important;
    transform:none!important;
    position:relative!important;
    top:auto!important;
    bottom:auto!important;
  }
  html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active:not(.qadha-drawing-focus) .premium-board-footer.qadha-reference-footer > .team-0{
    grid-column:3!important;
  }
  html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active:not(.qadha-drawing-focus) .premium-board-footer.qadha-reference-footer > .team-1{
    grid-column:1!important;
  }
  html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active:not(.qadha-drawing-focus) .premium-board-footer.qadha-reference-footer > .modern-turn-arrow{
    grid-column:2!important;
    grid-row:1!important;
    align-self:center!important;
    margin:0!important;
    transform:none!important;
  }
  html[data-ui-mode="modern"] body[data-game-brand="qadha"].q-game-active.qadha-drawing-focus .q-question-screen-v129{
    margin:0!important;
    height:calc(100dvh - 8px)!important;
    max-height:calc(100dvh - 8px)!important;
    box-sizing:border-box!important;
  }
}


/* r740f — outrank qadha-experience-v1's persistent app-shell width/margin during active play. */
@media (min-width:901px) and (min-height:620px){
  :root[data-ui-mode="modern"] body.fbrkh-next-shell[data-game-brand="qadha"].q-game-active #qApp{
    position:fixed!important;
    inset:0!important;
    top:0!important;
    right:0!important;
    bottom:0!important;
    left:0!important;
    width:100vw!important;
    max-width:none!important;
    height:100dvh!important;
    max-height:none!important;
    min-height:0!important;
    margin:0!important;
    transform:none!important;
    transform-origin:center!important;
    box-sizing:border-box!important;
  }
}


/* r741 — compact Qadha account control: keep the avatar-only mobile control visually contained without clipping. */
@media (max-width:760px){
  :root[data-ui-mode="modern"] body[data-game-brand="qadha"] .q-nav nav > #qAccountBtn{
    height:52px!important;
    min-height:52px!important;
    max-height:52px!important;
    overflow:visible!important;
  }
}
