/*
 * Responsive layout fixes for the application shell and top navigation.
 * The application is a fixed-height flex column. These sections must never
 * shrink, otherwise their children overflow and paint over the next view.
 */
.topbar,
.auth-layout,
.home-view,
.search-view,
.game-view {
  flex-shrink: 0;
}

/* Phones in landscape and small tablets use the compact two-row header too. */
@media (max-width: 900px) {
  .topbar {
    box-sizing: border-box;
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    column-gap: 10px;
    row-gap: 11px;
    align-items: center;
    align-content: start;
    width: min(calc(100% - 32px), 1180px);
    min-height: 0;
    height: auto;
    margin: 0 auto;
    padding: 14px 0 16px;
    overflow: visible;
  }

  .topbar .brand {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
  }

  .topbar .account-box {
    grid-column: 2;
    grid-row: 1;
    align-self: center;
    justify-self: end;
    position: static;
    min-width: 0;
  }

  .topbar .header-center {
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
    align-items: stretch;
    justify-content: stretch;
    justify-self: stretch;
    position: static;
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 0;
    transform: none;
  }

  .topbar .server-pill {
    display: none;
  }

  .topbar .text-size-button,
  .topbar .rules-button {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 0;
    min-height: 42px;
    height: auto;
    margin: 0;
    padding: 9px 12px;
    line-height: 1.15;
    white-space: nowrap;
  }

  .app-shell > .auth-layout,
  .app-shell > .home-view,
  .app-shell > .search-view,
  .app-shell > .game-view {
    flex: 0 0 auto;
  }

  .auth-layout,
  .home-view,
  .search-view,
  .game-view {
    margin-left: auto;
    margin-right: auto;
  }

  .large-text .topbar {
    flex: 0 0 auto;
    min-height: 0;
    height: auto;
  }

  .large-text .topbar .header-center {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    flex-wrap: nowrap;
  }

  .large-text .topbar .text-size-button,
  .large-text .topbar .rules-button {
    flex: none;
    min-height: 48px;
    padding: 10px 9px;
    font-size: 14px;
  }
}

@media (max-width: 680px) {
  .topbar {
    width: min(calc(100% - 24px), 1180px);
    padding-top: max(14px, env(safe-area-inset-top));
  }

  /* Remove vertical auto margins: the view begins after the full header. */
  .auth-layout {
    margin-top: 0;
    margin-bottom: 0;
    padding-top: 32px;
    padding-bottom: 48px;
  }

  .home-view {
    margin-top: 0;
    margin-bottom: 0;
    padding-top: 32px;
  }

  .hero-copy,
  .welcome {
    margin-top: 0;
  }

  .hero-copy > .eyebrow,
  .welcome .eyebrow {
    position: relative;
    z-index: 1;
  }

  .large-text .auth-layout,
  .large-text .home-view {
    padding-top: 36px;
  }
}

@media (max-width: 410px) {
  .topbar .text-size-button,
  .topbar .rules-button {
    min-height: 40px;
    padding-inline: 8px;
    font-size: 11px;
  }

  .large-text .topbar .text-size-button,
  .large-text .topbar .rules-button {
    min-height: 46px;
    padding-inline: 7px;
    font-size: 13px;
  }

  .topbar .rules-button svg {
    display: block;
    flex: 0 0 auto;
  }
}

@media (max-width: 350px) {
  .topbar {
    width: min(calc(100% - 18px), 1180px);
  }

  .topbar .header-center {
    gap: 6px;
  }

  .topbar .text-size-button,
  .topbar .rules-button {
    padding-inline: 6px;
  }

  .topbar .text-size-button svg,
  .topbar .rules-button svg {
    display: none;
  }
}
