:is(html.steam-gifts-route body, body:has(> .dt-game-service-section > .steam-header)) :is(.game-header, .steam-header) {
  --steam-header-logo-size: 130px;
  display: grid !important;
  grid-template-columns: var(--steam-header-logo-size) minmax(0, 1fr) !important;
  align-items: start !important;
  gap: 20px !important;
  padding: 0 !important;
  text-align: left !important;
}

:is(html.steam-gifts-route body, body:has(> .dt-game-service-section > .steam-header)) :is(.game-header, .steam-header) > :is(.game-logo, .steam-logo) {
  width: var(--steam-header-logo-size) !important;
  height: var(--steam-header-logo-size) !important;
  min-width: var(--steam-header-logo-size) !important;
  min-height: var(--steam-header-logo-size) !important;
  max-width: var(--steam-header-logo-size) !important;
  max-height: var(--steam-header-logo-size) !important;
  grid-area: 1 / 1 !important;
  justify-self: start !important;
  align-self: start !important;
  margin: 0 !important;
  object-fit: contain;
}

:is(html.steam-gifts-route body, body:has(> .dt-game-service-section > .steam-header)) :is(.game-header, .steam-header) h1 {
  min-width: 0;
  margin: 0 !important;
  font-size: var(--game-h2, 34px) !important;
  line-height: 1.2 !important;
  white-space: normal;
  text-align: left !important;
  text-wrap: balance;
}

:is(html.steam-gifts-route body, body:has(> .dt-game-service-section > .steam-header)) :is(.game-header, .steam-header) > :is(.game-header-content, .steam-title) {
  grid-area: 1 / 2 !important;
}

html.steam-gifts-route .game-header > .game-header-content {
  min-width: 0 !important;
  margin: 0 !important;
  width: 100% !important;
}

:is(html.steam-gifts-route body:has(main #products[data-testid="products"]), body:has(> .dt-game-service-section > .steam-header)) .dt-public-top-rail > .dt-public-top-rail__inner {
  flex-direction: row !important;
  align-items: center !important;
}

:is(html.steam-gifts-route body:has(main #products[data-testid="products"]), body:has(> .dt-game-service-section > .steam-header)) .dt-public-top-rail__inner .dt-public-top-rail__breadcrumbs {
  display: flex !important;
  height: auto !important;
  align-items: center !important;
  align-self: center !important;
}

@media (max-width: 1024px) {
  :is(html.steam-gifts-route body, body:has(> .dt-game-service-section > .steam-header)) :is(.game-header, .steam-header) {
    --steam-header-logo-size: 96px;
  }
}

@media (max-width: 699px) {
  :is(html.steam-gifts-route body, body:has(> .dt-game-service-section > .steam-header)) :is(.game-header, .steam-header) {
    --steam-header-logo-size: 82px;
  }

  body:has(> .dt-game-service-section > .steam-header) > .dt-game-service-section > .steam-header {
    /* The form adds the other 8px of the shared 16px gap. */
    margin-block-end: var(--space-2, 8px);
  }

  html.steam-gifts-route .game-header:has(.steam-gifts-search-wrap) > .game-header-content {
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    gap: 0 !important;
  }

  html.steam-gifts-route .game-header-content .steam-gifts-search-wrap {
    width: 100% !important;
    max-width: 100% !important;
    margin: 16px 0 0 !important;
  }

  :is(html.steam-gifts-route body:has(main #products[data-testid="products"]), body:has(> .dt-game-service-section > .steam-header)) .dt-public-top-rail > .dt-public-top-rail__inner {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  :is(html.steam-gifts-route body:has(main #products[data-testid="products"]), body:has(> .dt-game-service-section > .steam-header)) .dt-public-top-rail__inner .dt-public-top-rail__breadcrumbs {
    display: flex !important;
    width: 100% !important;
    flex: 0 0 auto !important;
    justify-content: center !important;
    align-self: start !important;
  }

  :is(html.steam-gifts-route body, body:has(> .dt-game-service-section > .steam-header)) .navigation .dt-public-top-rail__breadcrumbs > :is(.navigation-sep, .navigation-current) {
    display: none !important;
  }
}

@media (width < 560px) {
  :is(html.steam-gifts-route body, body:has(> .dt-game-service-section > .steam-header)) :is(.game-header, .steam-header) {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 14px !important;
  }

  :is(html.steam-gifts-route body, body:has(> .dt-game-service-section > .steam-header)) :is(.game-header, .steam-header) > :is(.game-logo, .steam-logo) {
    justify-self: center !important;
  }

  :is(html.steam-gifts-route body, body:has(> .dt-game-service-section > .steam-header)) :is(.game-header, .steam-header) h1 {
    line-height: 1.15 !important;
    text-align: center !important;
  }

  :is(html.steam-gifts-route body, body:has(> .dt-game-service-section > .steam-header)) :is(.game-header, .steam-header) > :is(.game-header-content, .steam-title) {
    grid-area: 2 / 1 !important;
  }
}

@media (560px <= width < 1025px) {
  html.steam-gifts-route body .game-header:has(.steam-gifts-search-wrap) {
    height: auto !important;
    row-gap: 0 !important;
  }

  html.steam-gifts-route body .game-header:has(.steam-gifts-search-wrap) > .game-header-content {
    display: contents !important;
  }

  html.steam-gifts-route body .game-header:has(.steam-gifts-search-wrap) h1 {
    grid-area: 1 / 2;
    align-self: center;
  }

  html.steam-gifts-route body .game-header .steam-gifts-search-wrap {
    grid-area: 2 / 2;
    margin-block-start: 16px !important;
  }

  body:has(> .dt-game-service-section > .steam-header) > .dt-game-service-section > .steam-header {
    grid-template-columns: var(--steam-header-logo-size) minmax(0, max-content) !important;
    justify-content: center !important;
  }

  body:has(> .dt-game-service-section > .steam-header) .steam-header > .steam-title {
    align-self: center;
  }
}

/* Keep the existing full-width search on narrower tablets. */
@media (560px <= width <= 699px) {
  html.steam-gifts-route body .game-header .steam-gifts-search-wrap {
    grid-area: 2 / 1 / 3 / -1;
  }
}

@media (700px <= width < 1025px) {
  body:has(> .dt-game-service-section > .steam-header) > .dt-game-service-section > .steam-header {
    /* The form already supplies the shared 16px gap. */
    margin-block-end: 0;
  }
}

@media (min-width: 1025px) {
  :is(html.steam-gifts-route body, body:has(> .dt-game-service-section > .steam-header)) :is(.game-header, .steam-header) {
    --steam-header-logo-size: 96px;
    --steam-header-desktop-spacing: var(--space-8, 32px);
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 14px !important;
  }

  :is(html.steam-gifts-route body, body:has(> .dt-game-service-section > .steam-header)) :is(.game-header, .steam-header) > :is(.game-logo, .steam-logo) {
    justify-self: center !important;
  }

  :is(html.steam-gifts-route body, body:has(> .dt-game-service-section > .steam-header)) :is(.game-header, .steam-header) > :is(.game-header-content, .steam-title) {
    grid-area: 2 / 1 !important;
  }

  :is(html.steam-gifts-route body, body:has(> .dt-game-service-section > .steam-header)) :is(.game-header, .steam-header) h1 {
    text-align: center !important;
  }

  html.steam-gifts-route body .game-header:has(.steam-gifts-search-wrap) > .game-header-content {
    min-height: 0 !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: var(--steam-header-desktop-spacing) !important;
  }

  body:has(> .dt-game-service-section > .steam-header) > .dt-game-service-section > .steam-header {
    /* Count the form's top padding as part of the shared gap. */
    margin-block-end: calc(var(--steam-header-desktop-spacing) - var(--space-4, 16px));
  }

  html.steam-gifts-route body .game-header .steam-gifts-search-wrap {
    margin-inline: auto !important;
  }
}
