/* Phone header: artwork, navigation, then profile in independent flow rows. */
@media (max-width:1000px), (max-width:1400px) and (pointer:coarse) {
  html body header:has(>.elb-battle-5v5):has(.header-player-panel) {
    display:grid!important;
    grid-template-columns:minmax(0,1fr)!important;
    grid-template-rows:auto auto auto!important;
    grid-auto-rows:auto!important;
    align-items:stretch!important;
    gap:8px 0!important;
    width:100%!important;
    min-width:0!important;
    height:auto!important;
    padding:0!important;
    overflow:visible!important;
  }
  html body header:has(>.elb-battle-5v5):has(.header-player-panel)>.elb-battle-5v5 {
    position:relative!important;
    inset:auto!important;
    grid-column:1!important;
    grid-row:1!important;
    width:100%!important;
    height:clamp(110px,22vw,190px)!important;
    min-height:0!important;
  }
  html body header:has(>.elb-battle-5v5):has(.header-player-panel)>.brand {
    display:none!important;
  }
  html body header:has(>.elb-battle-5v5):has(.header-player-panel)>nav {
    position:relative!important;
    inset:auto!important;
    grid-column:1!important;
    grid-row:2!important;
    display:flex!important;
    flex-flow:row wrap!important;
    align-items:center!important;
    justify-content:flex-start!important;
    width:100%!important;
    min-width:0!important;
    height:auto!important;
    margin:0!important;
    padding:4px 8px!important;
    gap:6px!important;
    box-sizing:border-box!important;
    overflow-x:visible!important;
    overflow-y:visible!important;
  }
  html body header:has(>.elb-battle-5v5):has(.header-player-panel)>nav>.elb-art-clicker,
  html body header:has(>.elb-battle-5v5):has(.header-player-panel)>nav>.perfect5-link {
    flex:1 1 90px!important;
    width:90px!important;
    min-width:90px!important;
    margin:0!important;
    padding:0!important;
  }
  html body header:has(>.elb-battle-5v5):has(.header-player-panel) .header-player-panel {
    position:relative!important;
    inset:auto!important;
    grid-column:1!important;
    grid-row:3!important;
    grid-template-rows:auto auto auto!important;
    align-self:stretch!important;
    justify-self:stretch!important;
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    height:auto!important;
    margin:0!important;
    transform:none!important;
    box-sizing:border-box!important;
  }
  html body header:has(>.elb-battle-5v5):has(.header-player-panel) .header-social-toolbar {
    grid-template-columns:minmax(0,1.5fr) minmax(0,1fr)!important;
    height:auto!important;
    min-width:0!important;
  }
  html body header:has(>.elb-battle-5v5):has(.header-player-panel) .header-social-button {
    white-space:normal!important;
    overflow-wrap:anywhere!important;
    height:auto!important;
    min-height:44px!important;
    line-height:1.3!important;
  }
  html body header:has(>.elb-battle-5v5):has(.header-player-panel) .header-social-button>span {
    min-width:0!important;
    white-space:normal!important;
  }
  html body header:has(>.elb-battle-5v5):has(.header-player-panel) .header-requests-dropdown {
    position:relative!important;
    inset:auto!important;
    grid-column:1/-1!important;
    grid-row:4!important;
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    max-height:65vh!important;
    margin:0!important;
    box-sizing:border-box!important;
    overflow:auto!important;
    overflow-wrap:anywhere!important;
  }
}

/* Let the entire profile and open requests participate in header sizing. */
html body header:has(>.elb-battle-5v5):has(.header-player-panel) .header-player-panel {
 grid-template-rows:auto auto auto!important;
 grid-auto-rows:auto!important;
 max-height:none!important;
 margin-bottom:0!important;
}
html body header:has(>.elb-battle-5v5):has(.header-player-panel) .header-social-toolbar {
 grid-template-columns:minmax(0,1.5fr) minmax(0,1fr)!important;
 height:auto!important;
}
html body header:has(>.elb-battle-5v5):has(.header-player-panel) .header-social-button {
 white-space:normal!important;
 height:auto!important;
 min-height:44px!important;
}
html body header:has(>.elb-battle-5v5):has(.header-player-panel) .header-requests-dropdown {
 position:relative!important;
 inset:auto!important;
 grid-column:1/-1!important;
 grid-row:4!important;
 width:100%!important;
 max-width:100%!important;
 margin:0!important;
}
html body header:has(>.elb-battle-5v5):has(.header-player-panel)>nav {
 margin-top:0!important;
}

/* Larger award icons and totals on touch devices. */
@media (max-width:650px), (max-width:1400px) and (pointer:coarse) {
 html body header:has(>.elb-battle-5v5):has(.header-player-panel) .header-player-panel .header-trophy-counts {
  grid-template-rows:auto!important;
  grid-template-columns:repeat(4,minmax(0,1fr))!important;
  width:100%!important;
 }
 html body header:has(>.elb-battle-5v5):has(.header-player-panel) .header-player-panel .header-trophy-counter {
  grid-template-columns:32px auto!important;
  grid-template-rows:36px 16px!important;
  column-gap:7px!important;
  height:76px!important;
  padding:10px 6px!important;
 }
 html body header:has(>.elb-battle-5v5):has(.header-player-panel) .header-player-panel .header-trophy-counter img,
 html body header:has(>.elb-battle-5v5):has(.header-player-panel) .header-player-panel .header-trophy-counter svg {
  width:32px!important;height:32px!important;
 }
 html body header:has(>.elb-battle-5v5):has(.header-player-panel) .header-player-panel .header-trophy-counter strong {
  font-size:30px!important;line-height:1!important;
 }
}

/* Phone navigation only: nine equal links, with no flex overflow or stretched final item. */
@media (max-width:1000px), (max-width:1400px) and (pointer:coarse) {
 html body header:has(>.elb-battle-5v5):has(.header-player-panel)>nav {
  display:grid!important;
  grid-template-columns:repeat(9,minmax(0,1fr))!important;
  grid-auto-rows:auto!important;
  align-items:center!important;
  gap:3px!important;
  padding:4px!important;
  overflow:visible!important;
 }
 html body header:has(>.elb-battle-5v5):has(.header-player-panel)>nav>.elb-art-clicker,
 html body header:has(>.elb-battle-5v5):has(.header-player-panel)>nav>.perfect5-link {
  display:flex!important;
  align-items:center!important;
  justify-content:center!important;
  width:100%!important;
  min-width:0!important;
  max-width:100%!important;
  min-height:44px!important;
  height:auto!important;
  margin:0!important;
  padding:0!important;
  border:0!important;
  background:transparent!important;
  box-sizing:border-box!important;
 }
 html body header:has(>.elb-battle-5v5):has(.header-player-panel)>nav>.elb-art-clicker img,
 html body header:has(>.elb-battle-5v5):has(.header-player-panel)>nav>.perfect5-link img {
  display:block!important;
  width:100%!important;
  height:auto!important;
  max-width:100%!important;
  object-fit:contain!important;
 }
}
@media(max-width:650px) {
 html body header:has(>.elb-battle-5v5):has(.header-player-panel)>nav {
  grid-template-columns:repeat(3,minmax(0,1fr))!important;
 }
}

/* Fixed mobile link grid: no horizontal carousel. */
@media (max-width:650px), (hover:none) and (pointer:coarse) {
 html body header:has(>.elb-battle-5v5):has(.header-player-panel)>nav {
  display:grid!important;
  grid-template-columns:repeat(3,minmax(0,1fr))!important;
  grid-auto-flow:row!important;
  grid-auto-columns:minmax(0,1fr)!important;
  width:100%!important;
  max-width:100%!important;
  min-width:0!important;
  box-sizing:border-box!important;
  overflow-x:clip!important;
  overflow-y:visible!important;
  scroll-snap-type:none!important;
  gap:4px!important;
  padding:4px 8px!important;
 }
 html body header:has(>.elb-battle-5v5):has(.header-player-panel)>nav>* {
  min-width:0!important;
  width:100%!important;
  max-width:100%!important;
  box-sizing:border-box!important;
  margin:0!important;
 }
 html body header:has(>.elb-battle-5v5):has(.header-player-panel)>nav img {
  max-width:100%!important;
  max-height:54px!important;
  width:100%!important;
  height:auto!important;
  object-fit:contain!important;
 }
}

/* Compact mobile award boxes around the enlarged icons and totals. */
@media (max-width:650px), (hover:none) and (pointer:coarse) {
 html body header:has(>.elb-battle-5v5):has(.header-player-panel) .header-player-panel .header-trophy-counts {
  grid-template-columns:repeat(4,max-content)!important;
  grid-template-rows:auto!important;
  justify-content:start!important;
  align-self:start!important;
  gap:6px!important;
 }
 html body header:has(>.elb-battle-5v5):has(.header-player-panel) .header-player-panel .header-trophy-counter {
  grid-template-columns:32px max-content!important;
  grid-template-rows:32px 12px!important;
  column-gap:4px!important;
  row-gap:2px!important;
  width:auto!important;
  height:auto!important;
  min-height:0!important;
  padding:5px 6px!important;
 }
 html body header:has(>.elb-battle-5v5):has(.header-player-panel) .header-player-panel .header-trophy-counter small {
  line-height:12px!important;
  letter-spacing:0!important;
 }
}

/* Mobile smile navigation shares the expanded artwork row. */
@media (max-width:650px), (hover:none) and (pointer:coarse) {
 html body header:has(>.elb-battle-5v5):has(.header-player-panel) {
  grid-template-columns:minmax(0,1fr)!important;
  grid-template-rows:auto auto!important;
  gap:8px 0!important;
 }
 html body header:has(>.elb-battle-5v5):has(.header-player-panel)>.elb-battle-5v5 {
  position:relative!important;
  inset:auto!important;
  grid-column:1!important;grid-row:1!important;
  width:100%!important;
  height:clamp(300px,40vw,420px)!important;
  min-height:300px!important;
 }
 html body header:has(>.elb-battle-5v5):has(.header-player-panel) .elb-premium-art {
  width:100%!important;height:100%!important;object-fit:fill!important;
 }
 html body header:has(>.elb-battle-5v5):has(.header-player-panel)>nav {
  position:relative!important;
  grid-column:1!important;grid-row:1!important;
  align-self:end!important;
  display:grid!important;
  grid-template-columns:repeat(9,minmax(0,1fr))!important;
  gap:2px!important;
  padding:0 6px 8px!important;
  margin:0!important;
  height:60px!important;
  overflow:visible!important;
  z-index:4!important;
  background:transparent!important;
  pointer-events:none;
 }
 html body header:has(>.elb-battle-5v5):has(.header-player-panel)>nav>* {
  pointer-events:auto;
  align-self:center!important;
  min-height:44px!important;
  transform:translateY(var(--smile-y,0px))!important;
 }
 html body header:has(>.elb-battle-5v5):has(.header-player-panel)>nav>:nth-child(1),
 html body header:has(>.elb-battle-5v5):has(.header-player-panel)>nav>:nth-child(9){--smile-y:-76px}
 html body header:has(>.elb-battle-5v5):has(.header-player-panel)>nav>:nth-child(2),
 html body header:has(>.elb-battle-5v5):has(.header-player-panel)>nav>:nth-child(8){--smile-y:-40px}
 html body header:has(>.elb-battle-5v5):has(.header-player-panel)>nav>:nth-child(3),
 html body header:has(>.elb-battle-5v5):has(.header-player-panel)>nav>:nth-child(7){--smile-y:-12px}
 html body header:has(>.elb-battle-5v5):has(.header-player-panel)>nav>:nth-child(5){--smile-y:4px}
 html body header:has(>.elb-battle-5v5):has(.header-player-panel) .header-player-panel {
  grid-column:1!important;grid-row:2!important;
 }
}

/* Compact mobile links across the bottom artwork border. */
@media (max-width:1000px), (max-width:1400px) and (pointer:coarse), (hover:none) and (pointer:coarse) {
 html body header:has(>.elb-battle-5v5):has(.header-player-panel)>nav {
  grid-column:1!important;grid-row:1!important;align-self:end!important;
  display:grid!important;grid-template-columns:repeat(9,minmax(0,1fr))!important;
  grid-auto-flow:row!important;gap:2px!important;
  width:100%!important;max-width:100%!important;min-width:0!important;
  height:clamp(36px,6vw,64px)!important;min-height:0!important;
  padding:0 4px 3px!important;margin:0!important;
  background:transparent!important;overflow:visible!important;
  box-sizing:border-box!important;pointer-events:none!important;z-index:4!important;
 }
 html body header:has(>.elb-battle-5v5):has(.header-player-panel)>nav>* {
  --smile-y:0px!important;transform:none!important;
  flex:0 1 auto!important;align-self:center!important;
  width:100%!important;min-width:0!important;max-width:100%!important;
  height:100%!important;min-height:0!important;max-height:60px!important;
  margin:0!important;padding:0!important;pointer-events:auto!important;
 }
 html body header:has(>.elb-battle-5v5):has(.header-player-panel)>nav img {
  display:block!important;width:100%!important;max-width:100%!important;
  height:auto!important;max-height:48px!important;object-fit:contain!important;
 }
 html body header:has(>.elb-battle-5v5):has(.header-player-panel) .header-player-panel {
  grid-row:2!important;
 }
}

/* Keep the mobile document within the device viewport. */
@media (max-width:1000px), (max-width:1400px) and (pointer:coarse), (hover:none) and (pointer:coarse) {
 html {width:100%!important;max-width:100%!important;min-width:0!important;overflow-x:hidden!important;overflow-x:clip!important;}
 html body {width:100%!important;max-width:100%!important;min-width:0!important;margin:0!important;overflow-x:hidden!important;overflow-x:clip!important;}
 html body #root {width:100%!important;max-width:100%!important;min-width:0!important;}
 html body header,html body .site-header,html body main,html body footer {
  width:100%!important;max-width:100%!important;min-width:0!important;box-sizing:border-box!important;
 }
 html body main {padding-left:8px!important;padding-right:8px!important;}
 html body main *,html body header .header-player-panel * {min-width:0;box-sizing:border-box;}
 html body main>*,html body main section,html body main article,
 html body .lc-dashboard>*,html body .lc-together>*,html body .mr-workspace>* {
  min-width:0!important;max-width:100%!important;
 }
 html body main img,html body main video,html body main canvas {max-width:100%!important;}
 html body main input,html body main select,html body main textarea {max-width:100%!important;}
 html body .lc-deadline {min-width:0!important;}
 html body .header-player-name,html body main h1,html body main h2 {overflow-wrap:anywhere;}
 html body .board-scroll,html body .scoreboard-team,html body .mi-table-scroll,html body .mr-scroll {
  min-width:0!important;max-width:100%!important;overflow-x:auto!important;
 }
}
@media(max-width:650px) {
 html body .mr-workspace {grid-template-columns:minmax(0,1fr)!important;}
 html body .mr-workspace>* {grid-column:1!important;grid-row:auto!important;}
 html body .lc-prediction-grid {grid-template-columns:minmax(0,1fr)!important;}
 html body .header-player-panel .header-trophy-counts {max-width:100%!important;gap:4px!important;}
}

/* Tight mobile award borders: do not reserve an empty caption row. */
@media (max-width:1000px), (max-width:1400px) and (pointer:coarse), (hover:none) and (pointer:coarse) {
 html body header:has(>.elb-battle-5v5):has(.header-player-panel) .header-player-panel .header-trophy-counter {
  grid-template-rows:32px auto!important;
  row-gap:0!important;
  height:auto!important;
  min-height:0!important;
  padding-top:4px!important;
  padding-bottom:4px!important;
  align-self:start!important;
 }
}

/* Fit every navigation item inside the header, including Store. */
html body header.elb-has-mapresearch:has(>.elb-battle-5v5)>nav {
 display:grid!important;grid-template-columns:repeat(9,minmax(0,1fr))!important;
 width:100%!important;max-width:100%!important;min-width:0!important;
 margin-left:0!important;margin-right:0!important;padding-left:4px!important;padding-right:4px!important;
 gap:2px!important;justify-content:center!important;box-sizing:border-box!important;
 overflow:visible!important;left:auto!important;right:auto!important;transform:none!important;
}
html body header.elb-has-mapresearch:has(>.elb-battle-5v5)>nav>* {
 width:100%!important;min-width:0!important;max-width:100%!important;
 margin:0!important;padding:0!important;box-sizing:border-box!important;transform:none!important;
}
html body header.elb-has-mapresearch:has(>.elb-battle-5v5)>nav>*>img {
 display:block!important;width:100%!important;max-width:100%!important;min-width:0!important;
 height:auto!important;object-fit:contain!important;
}
html body header:has(>.elb-battle-5v5)>.elb-header-home {
 display:block!important;position:absolute!important;inset:0!important;z-index:1!important;
 background:transparent!important;border:0!important;padding:0!important;margin:0!important;
}
html body header:has(>.elb-battle-5v5)>.elb-header-home:focus-visible {outline:2px solid #ffce54;outline-offset:-3px;}

/* Fill one row with the actual link count; remove inherited header offset. */
html body header.elb-has-mapresearch:has(>.elb-battle-5v5)>nav {
 grid-template-columns:none!important;grid-auto-flow:column!important;
 grid-auto-columns:minmax(0,1fr)!important;
}
@media (max-width:1000px), (max-width:1400px) and (pointer:coarse), (hover:none) and (pointer:coarse) {
 html body {padding-left:0!important;padding-right:0!important;}
 html body #root {margin-left:0!important;margin-right:0!important;padding-left:0!important;padding-right:0!important;}
 html body header:has(>.elb-battle-5v5) {
 margin-left:0!important;margin-right:0!important;left:0!important;right:auto!important;
 width:100%!important;max-width:100%!important;min-width:0!important;
 box-sizing:border-box!important;transform:none!important;justify-self:stretch!important;
 }
}
