/* Compact popups on phones (portrait and landscape) — zoom lobby panels and dialogs out
   and tighten layouts so more content fits without scrolling. Normal desktop screens are
   untouched. Loaded last so it wins over per-panel rules. max-height is divided by the
   zoom factor so the popup still fills the same screen height.
   "Phone" = narrow (portrait, <=760px wide) or short (landscape phone, <=520px tall). */
:root{--pz:1}
@media (max-width:760px){:root{--pz:.84}}
@media (max-width:760px) and (max-height:700px){:root{--pz:.78}}
@media (max-height:520px) and (orientation:landscape){:root{--pz:.74}}
@media (max-height:400px) and (orientation:landscape){:root{--pz:.68}}

/* ---------- all phones: zoom + compact headers/featured card ---------- */
@media (max-width:760px),(max-height:520px) and (orientation:landscape){
  #lobby-panel[data-panel] .lobby-panel-card{
    zoom:var(--pz);
    max-height:calc((100dvh - 16px) / var(--pz));
  }
  /* store is full-screen on phones (store-arena.css sets height:100dvh) — keep it full after zoom */
  body #lobby-panel[data-panel="store"] .lobby-panel-card,
  #home-screen[data-lobby-view] #lobby-panel[data-panel="store"] .lobby-panel-card{
    height:calc(100dvh / var(--pz))!important;max-height:calc(100dvh / var(--pz))!important;
  }
  body dialog.game-dialog,body dialog.app-dialog,body dialog#modal,
  body dialog.commerce-dialog,body dialog.format-dialog{
    zoom:var(--pz);
    max-height:calc((100dvh - 16px) / var(--pz))!important;
  }

  /* Duels Arena — header */
  #lobby-panel[data-panel="duels"] .lobby-pane[data-lobby-pane="duels"]{padding:10px 10px 12px}
  .da-arena{gap:8px}
  .da-hero-ico{width:38px;height:38px;font-size:19px;border-radius:11px}
  .da-title{font-size:26px}
  .da-sub{display:none}
  .da-stat{padding:5px 8px;gap:6px}
  .da-stat b{font-size:15px}
  .da-tabs button{min-height:34px}

  /* Duels Arena — featured card */
  .da-featured{padding:8px 10px 10px;border-radius:14px}
  .da-feat-top{margin-bottom:4px}
  .da-feat-stage{gap:6px;margin-bottom:8px;min-height:0}
  .da-fighter{gap:4px}
  .da-fighter .duel-av.da-portrait{width:54px;height:54px;font-size:22px;border-width:2px}
  .da-fighter-meta{padding:3px 8px;border-radius:9px}
  .da-vs-glow{width:38px;height:38px;font-size:12px}
  .da-target-box{min-width:0;padding:5px 8px}
  .da-target-box b{font-size:12px}
  .da-accept,.da-waiting-cta{min-height:36px;font-size:12px;border-radius:11px}

  /* Duels Arena — tighter rows */
  .da-list{gap:6px}
  .da-row{padding:7px 10px;border-radius:12px}
  .da-row-side .duel-av{width:32px;height:32px}
  .da-row-score b{font-size:13px}
  .da-btn{min-height:28px}
}

/* ---------- landscape phones: use the extra width ---------- */
@media (max-height:520px) and (orientation:landscape){
  .da-hero{align-items:center}

  /* featured card: avatar beside name, no info-only waiting strip */
  .da-feat-stage{margin-bottom:4px}
  .da-fighter{flex-direction:row;justify-content:center;gap:8px}
  .da-fighter.right{flex-direction:row-reverse}
  .da-fighter .duel-av.da-portrait{width:44px;height:44px}
  .da-feat-mid{flex-direction:row;gap:8px}
  .da-waiting-cta{display:none}
  .da-accept{min-height:32px}

  /* store / inventory: smaller cards so a full row plus buttons fits on screen */
  .sa-char-grid{grid-template-columns:repeat(6,minmax(0,1fr))!important}
  .sa-kit-grid{grid-template-columns:repeat(8,minmax(0,1fr))!important}
  .sa-layout{grid-template-columns:118px minmax(0,1fr)!important}
  .sa-cat{font-size:12px!important}

  /* treasure: the zoom frees vertical space, so give the chests room again */
  body [data-commerce-view="treasure"] .treasure-showcase{height:170px!important}
  body [data-commerce-view="treasure"] .treasure-chest-image{width:70%}
  body [data-commerce-view="treasure"] .treasure-ranges>div{font-size:11px;line-height:1.3}
  body [data-commerce-view="treasure"] .treasure-ranges .club-icon{width:26px!important;height:27px!important;padding:3px!important}
  body [data-commerce-view="treasure"] .treasure-ranges b{font-size:13px!important}
  body [data-commerce-view="treasure"] .treasure-ranges small{font-size:10px!important}
  body [data-commerce-view="treasure"] .commerce-box h4{font-size:28px!important}
  body [data-commerce-view="treasure"] .treasure-tagline{font-size:13px!important;margin:4px 0 10px!important}
  body [data-commerce-view="treasure"] .commerce-box .commerce-button{min-height:44px;font-size:16px}
  body [data-commerce-view="treasure"] .treasure-info{font-size:11px!important}

  /* login / signup: wider dialog, fields in two columns */
  body dialog#auth-modal{width:min(760px,calc((100vw - 24px) / var(--pz)))!important;max-width:none!important}
  #auth-modal .dialog-brand{padding:12px 50px 4px!important}
  #auth-modal .dialog-eyebrow{display:none!important}
  #auth-modal .dialog-brand strong{font-size:24px!important}
  #auth-modal .tabs{margin:6px 16px 4px}
  #auth-modal .dialog-form{display:grid;grid-template-columns:1fr 1fr;column-gap:14px;row-gap:6px;padding:4px 16px 8px}
  #auth-modal .dialog-form>p,#auth-modal .dialog-form>button{grid-column:1 / -1}
  #auth-modal .dialog-form p:empty{display:none}
  #auth-modal .dialog-form .action{margin-top:4px!important}
  #auth-modal .action.ghost.action-block{margin:0 16px 12px!important;width:calc(100% - 32px)}
}

/* ---------- portrait phones: one-line duel rows, 3-up store ---------- */
@media (max-width:760px){
  .da-hero{flex-direction:row;align-items:center;flex-wrap:wrap;gap:8px;padding-right:44px}
  .da-stats{width:calc(100% + 44px);margin-right:-44px;gap:6px}
  .da-stat{padding:5px 6px}

  /* [you] VS [opp] | status + button */
  .da-row{grid-template-columns:minmax(0,1fr) 78px;gap:8px;padding:7px 8px}
  .da-row-match{grid-template-columns:minmax(0,1fr) 24px minmax(0,1fr);gap:4px}
  .da-row-vs{width:24px;height:24px;font-size:8px}
  .da-row-side,.da-row-side.opp{
    display:grid;grid-template-columns:28px minmax(0,1fr);
    grid-template-areas:"av name" "av score";column-gap:5px;row-gap:1px;
  }
  .da-row-side.opp{grid-template-columns:minmax(0,1fr) 28px;grid-template-areas:"name av" "score av"}
  .da-row-side .duel-av{grid-area:av;width:28px;height:28px;order:0}
  .da-row-side .da-row-copy{grid-area:name;order:0}
  .da-row-side .da-row-score,.da-row-side.opp .da-row-score{
    grid-area:score;grid-column:auto;order:0;padding:0;min-width:0;text-align:left;
  }
  .da-row-side.opp .da-row-copy,.da-row-side.opp .da-row-score{text-align:right}
  .da-row-copy strong{font-size:11px}
  .da-row-copy small,.da-row-score span{display:none}
  .da-row-score b{font-size:12px;line-height:1.1}
  .da-row-actions{flex-direction:column;align-items:stretch;gap:4px;justify-content:center}
  .da-row-status{min-width:0;text-align:center}
  .da-row-status small{display:none}
  .da-pill{padding:3px 6px;font-size:9px;white-space:nowrap}
  .da-btn{min-width:0;min-height:26px;padding:0 10px;font-size:10px;border-radius:8px}

  #lobby-panel .sa-char-grid{grid-template-columns:repeat(3,minmax(0,1fr))!important;gap:6px}
}
