#new_game_container {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  padding: 26px 24px 40px;
  background: #f7f9fc;

  .new_game_header {
    width: 100%;
    max-width: 940px;
    margin: 0 auto 18px;

    .page_title {
      margin: 0 0 4px;
      color: #263746;
    }

    p {
      margin: 0;
      color: #647181;
      line-height: 1.5;
    }
  }

  #game_sort_and_filter {
    box-sizing: border-box;
    width: 100%;
    max-width: 940px;
    margin: 0 auto 16px;
    padding: 12px 14px;
    border: 1px solid #d8e0e8;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(25, 48, 68, 0.04);

    .filter {
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      gap: 6px;
      padding: 0;

      .filter_link, .clear {
        box-sizing: border-box;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 34px;
        min-height: 34px;
        margin: 0;
        padding: 5px 7px;
        border: 1px solid #d8e0e8;
        border-radius: 7px;
        background: #f8fafc;
      }

      .filter_link {
        float: none;
        opacity: 0.5;

        &.selected {
          border-color: #78bddd;
          background: #eaf6fc;
          opacity: 1;
        }
      }

      .clear {
        color: #647181;
        font-size: 18px;
        line-height: 1;
      }
    }

    .sort {
      display: flex;
      align-items: center;
      justify-content: flex-end;
      top: 12px;
      right: 14px;
      height: 34px;

      .sort_link {
        box-sizing: border-box;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 34px;
        float: none;
        margin-left: 6px;
        padding: 8px 10px;
        border: 1px solid #d8e0e8;
        border-radius: 7px;
        background: #f8fafc;
        color: #526171;

        &.selected {
          border-color: #78bddd;
          background: #eaf6fc;
          color: #176b96;
        }
      }
    }
  }

  .game_and_submit {
    box-sizing: border-box;
    width: 100%;
    max-width: 940px;
    margin: 0 auto;
    flex-grow: 1;
    align-items: center;
  }

  .new_game {
    position: relative;
    min-width: 0;
    margin: 0;
    text-align: center;

    #game {
      box-sizing: border-box;
      min-width: 0;
      padding: 18px;
      border: 1px solid #d8e0e8;
      border-radius: 12px;
      background: #fff;
      box-shadow: 0 2px 8px rgba(25, 48, 68, 0.05);
    }

    .modes {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 260px));
      justify-content: center;
      gap: 16px;
      margin-top: 16px;
    }

    .options, .opponent {
      box-sizing: border-box;
      width: auto;
      min-width: 0;
      margin: 0;
      padding: 18px;
      border: 1px solid #d8e0e8;
      border-radius: 12px;
      background: #fff;
      box-shadow: 0 2px 8px rgba(25, 48, 68, 0.05);

      h2 {
        margin: 0 0 3px;
        padding: 0;
        color: #263746;
        font-size: 21px;
      }

      .section_hint {
        min-height: 38px;
        margin: 0 0 12px;
        color: #647181;
        font-size: 13px;
        line-height: 1.4;
      }

      ul {
        overflow: auto;
        max-height: 300px;
        border: 1px solid #d8e0e8;
        border-radius: 8px;
        background: #f8fafc;
      }
    }

    .options {
      .features .feature {
        border-top: 1px solid #e1e8ee;
        background: #f8fafc;
        color: #34475a;
        font-size: 18px;

        &:first-child {
          border-top: 0;
        }

        &:hover {
          background: #eef7fc;
        }

        &.selected {
          background: #dff4fd;
          color: #176b96;

          &:hover {
            background: #dff4fd;
          }
        }

        .choices .choice {
          border-top-color: #d8e0e8;
          background: #fff;

          &:hover {
            background: #eef7fc;
          }

          &.selected {
            background: #ccecfb;
          }
        }
      }
    }

    .opponent {
      text-align: center;

      ul {
        &::-webkit-scrollbar {
          -webkit-appearance: none;
          width: 7px;
          background: #eef2f5;
        }

        &::-webkit-scrollbar-thumb {
          border-radius: 4px;
          background: #ccc;
        }

        &::-webkit-scrollbar-track {
          background: #eee;
        }
      }

      .friend {
        box-sizing: border-box;
        clear: both;
        overflow: hidden;
        min-height: 42px;
        padding: 3px 8px 3px 3px;
        border-bottom: 1px solid #e1e8ee;
        font-size: 18px;
        font-family: 'Acme';
        line-height: 36px;
        cursor: pointer;
        white-space: nowrap;
        text-overflow: ellipsis;

        &:last-child {
          border-bottom: 0;
        }

        &:hover {
          background: #eef7fc;
        }

        .online {
          font-size: 12px;
          top: 2px;
          left: 2px;
        }

        .avatar {
          float: left;
          margin-right: 5px;
        }
      }

      .selected {
        background: #dff4fd;
        color: #176b96;

        &:hover {
          background: #dff4fd;
        }
      }
    }

    .submit_area {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 12px;
      margin: 16px auto 0;

      .dict {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        margin: 0;
        padding: 9px 12px;
        border: 1px solid #d8e0e8;
        border-radius: 8px;
        background: #fff;
        font-family: 'Acme';

        label {
          margin: 0;
          color: #34475a;
          font-size: 17px;
        }

        select {
          padding: 5px 7px;
          border: 1px solid #bdcad5;
          border-radius: 6px;
          background: #fff;
          color: #263746;
        }
      }

      .submit .btn_link {
        padding: 10px 18px;
        border: 1px solid #1686bb;
        border-radius: 8px;
        background: var(--btn-primary);
        color: #08354d;

        &:hover, &:focus-visible {
          border-color: #0874aa;
          background: #18a7e8;
        }

        &:focus-visible {
          outline: 2px solid #176b96;
          outline-offset: 2px;
        }
      }
    }
  }
}

@media (max-width: 700px) {
  #new_game_container {
    .new_game .modes {
      grid-template-columns: minmax(0, 1fr);
    }

    #game_sort_and_filter .sort {
      position: static;
      display: flex;
      flex-wrap: wrap;
      justify-content: flex-start;
      gap: 6px;
      height: auto;
      margin-top: 10px;

      .sort_link {
        margin: 0;
      }
    }
  }
}

@media (max-width: 480px) {
  #new_game_container {
    padding: 20px 12px 32px;

    .new_game_header {
      margin-bottom: 14px;

      .page_title {
        font-size: 28px;
      }
    }

    #game_sort_and_filter {
      padding: 10px;

      .sort {
        gap: 5px;
        margin-top: 8px;
      }
    }

    .new_game {
      #game {
        padding: 12px 10px;
      }

      .options, .opponent {
        padding: 16px 14px;
      }

      .submit_area {
        align-items: stretch;
        flex-direction: column;

        .dict {
          justify-content: center;
        }

        .submit .btn_link {
          width: 100%;
        }
      }
    }
  }
}
